<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../assert/css/font.css" th:href="@{/assert/css/font.css}"/>
    <link rel="stylesheet" href="../../../assert/css/plugin/chosen/chosen.css"
          th:href="@{/assert/css/plugin/chosen/chosen.css}"/>
    <link href="../../../assert/css/animate.min.css" rel="stylesheet" th:href="@{/assert/css/animate.min.css}">
    <link href="../../../assert/css/plugin/toastr/toastr.min.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/toastr/toastr.min.css}">
    <link href="../../../assert/css/plugin/jsTree/themes/default/style.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/jsTree/themes/default/style.css}">
    <link href="../../../assert/js/layui/css/layui.css" rel="stylesheet"
          th:href="@{/assert/js/layui/css/layui.css}" media="all">
    <link href="../../../assert/css/loaders.css" rel="stylesheet"
          th:href="@{/assert/css/loaders.css}">
    <link rel="stylesheet" href="../../../assert/css/bootstrap.min.css" th:href="@{/assert/css/bootstrap.min.css}"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap-table.css" th:href="@{/assert/css/bootstrap-table.css}"/>
    <link rel="stylesheet" href="../../../assert/css/jquery-ui.css" th:href="@{/assert/css/jquery-ui.css}"/>
    <link href="../../../assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/styles/jqx.base.css" rel="stylesheet"
          th:href="@{/assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/styles/jqx.base.css}"/>
    <link rel="stylesheet" href="../../../assert/css/index.css"
          th:href="@{/assert/css/index.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"/>
    <link rel="stylesheet" href="../../../assert/css/subpagesCss/rule.css"
          th:href="@{/assert/css/subpagesCss/rule.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"/>
</head>
<body class="oneStyle">
<div class="wrapper wrapper-content">
    <div class="ibox" id="box">
        <div class="model_left">
            <!--<h4 class="model_title">质检模型</h4>-->
            <div class="search_box">
                <input type="text" style="width: 174px;padding:1px 5px;" autocomplete="off"><span
                    class="fa fa-search fa_btn"
                    id="searchMenu"></span>
                <!--<span class="fa fa-plus fa_btn" id="addType" title="添加省级信息"></span>-->
            </div>

            <div id="jstree" class="scrollbar">

            </div>
        </div>
        <div class="model_right">
            <div class="tools_bar">
                <div class="pull-left">
                    <a href="#" class="btn btn-default active" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 隐藏</a>
                    <a href="#" class="btn btn-default active" id="refresh"><i class="fa fa-refresh"></i> 刷新</a>
                    <a href="#" class="btn btn-default active" id="btnAdd" title="添加质检规则"><i class="fa fa-plus"></i> 添加</a>
                    <a href="#" class="btn btn-default active" id="btnEdit" title="编辑质检规则"><i class="fa fa-pencil"></i>
                        编辑</a>
                    <a href="#" class="btn btn-default active" id="btnDel" title="删除质检规则"><i class="fa fa-remove"></i>
                        删除</a>
                    <a href="#" class="btn btn-default active" id="btnMove" title="移动质检规则"><i
                            class="fa fa-reply-all"></i> 移动至</a>
                    <a href="#" class="btn btn-default active" id="btnCopy" title="复制质检规则"><i class="fa fa-copy"></i> 复制</a>
                    <a href="#" style="margin-left:20px" class="btn btn-default active" id="btnStart" title="上线质检规则"><i
                            class="fa fa-long-arrow-up stateGreen"></i> 上线</a>
                    <a href="#" class="btn btn-default active" id="btnStop" title="下线质检规则"><i
                            class="fa fa-long-arrow-down stateRed"></i> 下线</a>

                </div>
            </div>
            <div class="search on">
                <div class="search_group hidden">
                    <label class="control-label">省份：</label>
                    <div class="control-inline">
                        <select type="text" id="pro" value="" class="form-control search_input"
                                data-code="pro"></select>
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">规则名称：</label>
                    <div class="control-inline">
                        <input type="text" id="rulename" value="" class="form-control search_input" autocomplete="off">
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">规则分类：</label>
                    <div class="control-inline">
                        <input type="text" id="classify" value="" class="form-control search_input" autocomplete="off"
                               readonly/>
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">规则属性：</label>
                    <div class="control-inline">
                        <select type="text" id="ruleattributes" value=""
                                class="form-control search_input chosen-select"></select>
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">发布状态：</label>
                    <div class="control-inline">
                        <select type="text" id="state" value=""
                                class="form-control search_input chosen-select"></select>
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">分值属性：</label>
                    <div class="control-inline">
                        <select type="text" id="scoreFlag" value=""
                                class="form-control search_input chosen-select"></select>
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">创建人员：</label>
                    <div class="control-inline">
                        <input type="text" id="person" value="" class="form-control search_input" autocomplete="off">
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">创建时间：</label>
                    <div class="control-inline">
                        <input placeholder="开始日期" class="form-control layer-date search_input" id="start"
                               autocomplete="off"> -
                        <input placeholder="结束日期" class="form-control layer-date search_input" id="end"
                               autocomplete="off">
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">上线时间：</label>
                    <div class="control-inline">
                        <input placeholder="开始日期" class="form-control layer-date search_input" id="startS"
                               autocomplete="off"> -
                        <input placeholder="结束日期" class="form-control layer-date search_input" id="endS"
                               autocomplete="off">
                    </div>
                </div>
                <div class="search_group">
                    <label class="control-label">更新时间：</label>
                    <div class="control-inline">
                        <input placeholder="开始日期" class="form-control layer-date search_input" id="startUp"
                               autocomplete="off"> -
                        <input placeholder="结束日期" class="form-control layer-date search_input" id="endUp"
                               autocomplete="off">
                    </div>
                </div>
                <div class="search_group hidden">
                    <label class="control-label">致命性：</label>
                    <div class="control-inline">
                        <select type="text" id="rulefatal" value=""
                                class="form-control search_input chosen-select"></select>
                    </div>
                </div>
                <div class="search_group">
                    <button id="search" class="btn  btn-primary">查询</button>
                    <button id="searchAll" class="btn  btn-primary">全查询</button>
                    <button id="reset" class="btn  btn-default">重置</button>
                </div>
            </div>
            <table id="myTable"></table>
        </div>
    </div>
    <div style="width: 100%;height: 100%;overflow: auto;display: none" class="ruleAllBox">
        <!--添加规则-->
        <div class="ibox" id="boxAdd" style="display: none;min-width: 1300px;">
            <div>
                <h4 class="modal-title" style="font-size: 16px;font-weight:bold">添加规则</h4>
                <div class="base-title">基本信息</div>
            </div>
            <div class="modal-body">
                <form method="post" class="form-horizontal" id="addModelForm">
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>分值属性:</label>
                            <div class="col-sm-9  radio">
                                <label style="margin-right:20px;"><input type="radio" name="scoreFlag" value="-1"
                                                                         checked>减分</label>
                                <label><input type="radio" name="scoreFlag" value="1">加分</label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-3 control-label" style="width:12.5%;"><span class="respan">*</span>规则名称:</label>
                        <div class="col-sm-9" style="width: 83.4%;">
                            <input name="note" class="form-control" id="ruleNameAdd" placeholder="最多输入50个字符">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>规则属性:</label>
                            <div class="col-sm-9">
                                <select name="" id="ruleAttrAdd"></select>
                            </div>
                        </div>
                        <div class="form-box">
                            <label for="" class="col-sm-2 control-label"><span class="respan">*</span>规则分类:</label>
                            <div class="col-sm-9">
                                <input name="note" class="form-control" id="ruleClassifyAdd" readonly>
                            </div>
                        </div>

                    </div>
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>是否致命项:</label>
                            <div class="col-sm-9">
                                <select id="fatalAdd"></select>
                            </div>
                        </div>
                        <div class="form-box">
                            <label for="" class="col-sm-2 control-label">建议评分:</label>
                            <div class="col-sm-9">
                                <input name="fullscore" id="scoreAdd" class="form-control" value=""
                                       autocomplete="off" placeholder="请输入大于等于0、小于等于10000的数字"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group remarkBox">
                        <label for="" class="col-sm-3 control-label" style="width:12.5%;">备注:</label>
                        <div class="col-sm-8" style="width: 83.4%;">
                            <textarea name="note" class="form-control" style="height:70px" id="remarkAdd"
                                      placeholder="最多输入255个字符"></textarea>
                        </div>
                    </div>
                </form>
                <div style="display: none;width: 100%;">
                    <div class="rule_left">
                        <div class="base-title addRuleTitle" data-code="add">添加子规则</div>
                        <form method="post" class="form-horizontal" id="subAddModelForm">
                            <div class="form-group">
                                <label for="" class="col-sm-3 control-label" style="width:2.5%;"></label>
                                <div class="col-sm-8" style="width: 97%;" id="addRuleTable">
                                    <div class="rule_box">
                                        <div class="tabTitle" style="height: 30px;line-height: 30px;">
                                            <span class="on" data-type="文本" data-code="idtext">文本规则</span>
                                            <span data-type="静音" data-code="idmute">静音规则</span>
                                            <span data-type="音量" data-code="idvolume">音量规则</span>
                                            <span data-type="语速" data-code="idvoicespeed">语速规则</span>
                                            <span data-type="负面情绪" data-code="idnegative">情绪规则</span>
                                            <span data-type="抢插话" data-code="idgrab">抢插话规则</span>
                                            <span data-type="声道" data-code="idchannels">声道规则</span>
                                        </div>
                                        <!--文本-->
                                        <div class="ibox-content tab tab0 on">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">文本内容:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <input name="note" class="form-control" id="textContent"
                                                               readonly>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute0"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute1"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP0"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">命中:</label>
                                                        <select class="hitP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--静音-->
                                        <div class="ibox-content tab tab1">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t0"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t1"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute2"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute3"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP1"
                                                               width="150">
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--音量-->
                                        <div class="ibox-content tab tab2">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">音量差值:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control y0"
                                                                   width="150"><span
                                                                class="sec">分贝</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control y1"
                                                                   width="150"><span
                                                                class="sec">分贝</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute4"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute5"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP2"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--语速-->
                                        <div class="ibox-content tab tab3">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">语速:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control s0"
                                                                   width="150"><span
                                                                class="sec">字/秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control s1"
                                                                   width="150"><span
                                                                class="sec">字/秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t8"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t9"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute6"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute7"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP3"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--情绪-->
                                        <div class="ibox-content tab tab4">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute8"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute9"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--抢插话-->
                                        <div class="ibox-content tab tab5">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute10"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute11"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP4"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--声道-->
                                        <div class="ibox-content tab tab6">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t2"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t3"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute12"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute13"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP5"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">命中:</label>
                                                        <select class="hitP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                    <div class="rule_right">
                        <div class="base-title">子规则列表</div>
                        <form method="post" class="form-horizontal" id="ruleAddModelForm">
                            <div class="form-group">
                                <label for="" class="col-sm-3 control-label" style="width:0%;"></label>
                                <div class="col-sm-8" style="width:100%;margin-top: 22px;">
                                    <table class="subTable"></table>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="save">保存</button>
                <button type="button" class="btn btn-white" id="closeAddBtn">关闭</button>
            </div>
        </div>
        <!--编辑规则-->
        <div class="ibox" id="boxEdit" style="display: none;min-width: 1300px;">
            <div>
                <h4 class="modal-title" style="font-size: 16px;font-weight:bold">编辑规则</h4>
                <div class="base-title">基本信息</div>
            </div>
            <div class="modal-body">
                <form method="post" class="form-horizontal" id="editForm">
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>分值属性:</label>
                            <div class="col-sm-9  radio">
                                <label style="margin-right:20px;"><input type="radio" name="scoreFlagEdit" value="-1"
                                                                         checked>减分</label>
                                <label><input type="radio" name="scoreFlagEdit" value="1">加分</label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-3 control-label" style="width:12.5%;"><span class="respan">*</span>规则名称:</label>
                        <div class="col-sm-9" style="width: 83.4%;">
                            <input name="note" class="form-control" id="ruleNameEdit">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>规则属性:</label>
                            <div class="col-sm-9">
                                <select name="" id="ruleAttrEdit" disabled></select>
                            </div>
                        </div>
                        <div class="form-box">
                            <label for="" class="col-sm-2 control-label"><span class="respan">*</span>规则分类:</label>
                            <div class="col-sm-9">
                                <input name="note" class="form-control" id="ruleClassifyEdit" readonly>
                            </div>
                        </div>

                    </div>
                    <div class="form-group">
                        <div class="form-box">
                            <label for="" class="col-sm-3 control-label"><span class="respan">*</span>是否致命项:</label>
                            <div class="col-sm-9">
                                <select id="fatalEdit"></select>
                            </div>
                        </div>
                        <div class="form-box">
                            <label for="" class="col-sm-2 control-label">建议评分:</label>
                            <div class="col-sm-9">
                                <input name="fullscore" id="scoreEdit" class="form-control" value=""
                                       autocomplete="off" placeholder="请输入大于等于0、小于等于10000的数字"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group remarkBox">
                        <label for="" class="col-sm-3 control-label" style="width:12.5%;">备注:</label>
                        <div class="col-sm-8" style="width: 83.4%;">
                            <textarea name="note" class="form-control" style="height:70px" id="remarkEdit"
                                      placeholder="最多输入255个字符"></textarea>
                        </div>
                    </div>
                </form>
                <div style="display: inline-block;width: 100%;">
                    <div class="rule_left">
                        <div class="base-title addRuleTitle" data-code="add">添加子规则</div>
                        <form method="post" class="form-horizontal" id="subEditModelForm">
                            <div class="form-group">
                                <label for="" class="col-sm-3 control-label" style="width:2.5%;"></label>
                                <div class="col-sm-8" style="width: 97%;" id="editRuleTable">
                                    <div class="rule_box">
                                        <div class="tabTitle" style="height: 30px;line-height: 30px;">
                                            <span class="on" data-type="文本" data-code="idtext">文本规则</span>
                                            <span data-type="静音" data-code="idmute">静音规则</span>
                                            <span data-type="音量" data-code="idvolume">音量规则</span>
                                            <span data-type="语速" data-code="idvoicespeed">语速规则</span>
                                            <span data-type="负面情绪" data-code="idnegative">情绪规则</span>
                                            <span data-type="抢插话" data-code="idgrab">抢插话规则</span>
                                            <span data-type="声道" data-code="idchannels">声道规则</span>
                                        </div>
                                        <!--文本-->
                                        <div class="ibox-content tab tab0 on">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">文本内容:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <input name="note" class="form-control" id="textContent"
                                                               readonly>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute14"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute15"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP6"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">命中:</label>
                                                        <select class="hitP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--静音-->
                                        <div class="ibox-content tab tab1">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t4"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t5"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute16"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute17"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP7"
                                                               width="150">
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--音量-->
                                        <div class="ibox-content tab tab2">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">音量差值:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control y2"
                                                                   width="150"><span
                                                                class="sec">分贝</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control y3"
                                                                   width="150"><span
                                                                class="sec">分贝</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute18"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute19"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP8"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--语速-->
                                        <div class="ibox-content tab tab3">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">语速:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control s2"
                                                                   width="150"><span
                                                                class="sec">字/秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control s3"
                                                                   width="150"><span
                                                                class="sec">字/秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t10"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t11"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute20"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute21"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP9"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--情绪-->
                                        <div class="ibox-content tab tab4">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute22"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute23"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--抢插话-->
                                        <div class="ibox-content tab tab5">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute24"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute25"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP10"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                        <!--声道-->
                                        <div class="ibox-content tab tab6">
                                            <div class="animated fadeInRight">
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">时长:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="minT form-control t6"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <span class="heng">-</span>
                                                        </div>
                                                        <div class="formSubBox formBox3">
                                                            <input type="text" class="maxT form-control t7"
                                                                   width="150" data-type="timeDur"><span
                                                                class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;">位置:</label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="absolute formSubBox">
                                                            <label for="" class="control-label">绝对位置:</label>
                                                            <select class="absolutePos"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute26"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="col-sm-3 control-label"
                                                           style="width:78px;"></label>
                                                    <div class="col-sm-9" style="width: 83.4%;">
                                                        <div class="relative formSubBox">
                                                            <label for="" class="control-label">相对位置:</label>
                                                            <select class="relativeObj"></select>
                                                            <select class="relativePos" style="width:100px"></select>
                                                            <input type="text"
                                                                   class="absoluteTxt form-control absolute27"
                                                                   style="width:100px"><span class="sec">秒</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">次数:</label>
                                                        <input type="text" class="countP form-control countP11"
                                                               width="150">
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">声道:</label>
                                                        <select class="speechP"></select>
                                                    </div>
                                                    <div class="formSubBox formBox3">
                                                        <label for="" class="control-label">命中:</label>
                                                        <select class="hitP"></select>
                                                    </div>
                                                </div>
                                                <div class="btns">
                                                    <button class="btn btn-primary saveRule" type="button">确定</button>
                                                    <button class="btn btn-default resetRule" type="button">取消</button>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="rule_right">
                        <div class="base-title">子规则列表</div>
                        <form method="post" class="form-horizontal" id="ruleEditModelForm">
                            <div class="form-group">
                                <label for="" class="col-sm-3 control-label" style="width:0%;"></label>
                                <div class="col-sm-8" style="width:100%;margin-top: 22px;">
                                    <table class="subTable"></table>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="saveEdit">保存</button>
                <button type="button" class="btn btn-white" id="closeEditBtn">关闭</button>
            </div>
        </div>
    </div>

</div>

<!--删除确认框-->
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">删除</h4>
                </div>
                <div class="modal-body">
                    <!--<div style="text-align: center;color:#ff0000;margin-bottom:10px;" id="delTextM"></div>-->
                    <div style="text-align: center">
                        <div>
                            <div class="tipBox"></div>
                        </div>
                        <span class="fa fa-question-circle"></span>
                        <span id="delName"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="delBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--上线/下线确认框-->
<div class="modal fade" id="startModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">上线</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center">
                        <div>
                            <div class="tipBox"></div>
                        </div>
                        <span class="fa fa-question-circle"></span>
                        <span id="type"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="startBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--复制 确认框-->
<div class="modal fade" id="copyModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">复制</h4>
            </div>
            <div class="modal-body">
                <div class="left">
                    <label for="" class="control-label" style="font-weight: bold;">质检规则目录:</label>
                    <div class="search_box">
                        <input type="text" autocomplete="off" style="width: 225px;"><span class="fa fa-search fa_btn"
                                                                                          id="searchMenuCopy"
                                                                                          style="top: -2px;"></span>
                    </div>
                    <div id="jsTreeCopy" class="scrollbar" style="height:400px;width:255px;">

                    </div>
                </div>
                <div class="right" style="width: 510px;">
                    <div class="ceng">请选择没有子分类的节点！</div>
                    <div style="display: none;">
                        <label for="" class="control-label" style="padding-left:127px;font-weight: bold;">原名称:</label>
                        <label for="" class="control-label" style="padding-left:136px;font-weight: bold;">重命名:</label>
                        <form method="post" class="form-horizontal" id="copyForm" style="text-align: center">
                            <ul class="nameList scrollbar">
                                <li><input type="text" class="oldName form-control" autocomplete="off"><span
                                        class="fa fa-long-arrow-right"></span><input type="text"
                                                                                     class="newName form-control"
                                                                                     autocomplete="off"></li>
                                <li><input type="text" class="oldName form-control" autocomplete="off"><span
                                        class="fa fa-long-arrow-right"></span><input type="text"
                                                                                     class="newName form-control"
                                                                                     autocomplete="off"></li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="copyBtn">确定</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>
<!--删除分类确认框-->
<div class="modal fade" id="delModalCon" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">删除</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center;color:#ff0000;margin-bottom:10px;" id="delText"></div>
                    <div style="text-align: center"><span class="fa fa-question-circle"></span>确定要删除 <span
                            id="delNameCon"></span> 吗？
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="delConBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--添加分类模态框-->
<div class="modal fade" id="addTypeModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post" class="form-horizontal" id="addTypeForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">添加分类</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="" class="col-sm-3 control-label">省份:</label>
                        <div class="col-sm-8">
                            <select name="provinceid" id="proTypeModal" data-code="pro"></select>
                            <input type="text" class="form-control selectInput" id="proTypeModalAddInput"
                                   autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group hidden">
                        <label for="" class="col-sm-3 control-label">上级分类:</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" id="typeParentModal" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-3 control-label">分类名称:</label>
                        <div class="col-sm-8">
                            <input type="text" name="name" id="modelTypeName" class="form-control" autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-3 control-label">备注:</label>
                        <div class="col-sm-8">
                            <textarea name="note" class="form-control" style="height:70px;"
                                      id="remarkTypeAdd"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="addTypeBtn">保存</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<form action="" id="exportForm" class="hidden" method="post" target="_self">
    <input type="text" id="provincecodeE" name="provincecode">
    <input type="text" id="nameE" name="modelname">
    <input type="text" id="typeidE" name="classify">
    <input type="text" id="stateE" name="state">
    <input type="text" id="startE" name="start">
    <input type="text" id="endE" name="end">
    <input type="text" id="personE" name="person">
</form>
<!--移动质检规则-->
<div class="modal fade" id="moveRuleModel" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width:500px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">移动质检规则</h4>
            </div>
            <div class="modal-body" style="overflow: hidden;">
                <div class="search_box">
                    <input type="text" autocomplete="off" style="width: 438px;"><span class="fa fa-search fa_btn"
                                                                                      id="searchMenuMove"
                                                                                      style="top: -3px;"></span>
                </div>
                <div id="jsTreeMove" class="scrollbar" style="height:600px;">

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="moveRuleBtn">确定</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--下线确认框-->
<div class="modal fade" id="stopCon" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">下线</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center">
                        <span class="fa fa-question-circle"></span>
                        <span id="stopConTip"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="stopConBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--删除子规则确认框-->
<div class="modal fade" id="delSubRuleModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">删除</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center;color:#ff0000;margin-bottom:10px;" id="delSubRuleText"></div>
                    <div style="text-align: center">
                        <div>
                            <div class="tipBox"></div>
                        </div>
                        <span class="fa fa-question-circle"></span>
                        <span id="delSubRuleName"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="delSubRuleBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--不保存修改确认框-->
<div class="modal fade" id="noSaveModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">确定</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center">
                        <span class="fa fa-question-circle"></span>
                        <span>确定不保存已修改内容？</span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="noSaveBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--选择文本模态框-->
<div class="modal fade" id="textModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width: 1000px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">选择文本内容</h4>
            </div>
            <div class="modal-body">
                <div class="text-msg">
                    <div><label for="">省份：</label><span id="textPro"></span></div>
                    <div><input type="text" placeholder="请输入查询数据"><span class="fa fa-search fa_btn"
                                                                        id="searchText"></span></div>
                    <div><label for="">已选数据：</label><span id="text"></span></div>
                </div>
                <div class="text-table">
                    <div class="text-tree">
                        <div id="jstreeText" class="scrollbar" style="max-height: 378px;">

                        </div>
                    </div>
                    <div class="standard-position">
                        <div class="table-title">请选择标准问题</div>
                        <table id="standardTable">

                        </table>
                    </div>
                    <div class="custom-position">
                        <div class="table-title">客户问题</div>
                        <table id="customTable">

                        </table>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="textBtn">确定</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<a id="basePath" th:href="@{/}"></a>
<input type="text" id="idservice" class="hidden">
<script src="../../../assert/js/jquery.js" th:src="@{/assert/js/jquery.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/bootstrap.min.js" th:src="@{/assert/js/bootstrap.min.js}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table.min.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script src="../../../assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script src="../../../assert/js/plugin/toastr/toastr.min.js"
        th:src="@{/assert/js/plugin/toastr/toastr.min.js}"></script>
<script src="../../../assert/js/base.js"
        th:src="@{/assert/js/base.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/jquery-ui.min.js" th:src="@{/assert/js/jquery-ui.min.js}"></script>
<script src="../../../assert/js/plugin/layer/laydate/laydate.js"
        th:src="@{/assert/js/plugin/layer/laydate/laydate.js}"></script>
<script src="../../../assert/js/changeTime.js"
        th:src="@{/assert/js/changeTime.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/plugin/jsTree/jstree.min.js"
        th:src="@{/assert/js/plugin/jsTree/jstree.min.js}"></script>
<script src="../../../assert/js/plugin/chosen/chosen.jquery.js"
        th:src="@{/assert/js/plugin/chosen/chosen.jquery.js}"></script>
<script src="../../../assert/js/layui/layui.js" th:src="@{/assert/js/layui/layui.js}"></script>
<script src="../../../assert/js/common.js"
        th:src="@{/assert/js/common.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/jqxcore.js"
        th:src="@{/assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/jqxcore.js}"></script>
<script src="../../../assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/jqxvalidator.js"
        th:src="@{/assert/js/lib/jqwidgets-ver4.0.0/jqwidgets/jqxvalidator.js}"></script>
<script>
    //项目名称
    var basePath = $("#basePath").attr("href");
    var json = [];
    var TableInit = function () {
        var oTableInit = new Object();
        var url = tools.ruleUrl + "/combinationRule/queryCombinationRule";
        var height = ($(window).height() -$(".tools_bar").height()-9-$(".search").height()-40);
        //初始化Table
        oTableInit.Init = function () {
            $('#myTable').bootstrapTable({
                url: url,         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortOrder: "desc",                   //排序方式
                sortName: "end_time", //排序方式
                pagination: true,//是否显示分页（*）
                height:height,
                queryParams: function (params) {
                    var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        // rows: params.limit,//页面大小
                        // page: (params.offset / params.limit) + 1//页码
                        pageSize: params.limit,   //页面大小
                        pageNum: params.offset / params.limit + 1,  //偏移量
                        sortName: this.sortName,
                        sortOrder: this.sortOrder,
                        idservice: $("#classify").attr("data-id"), //分类
                        rulename: $.trim($("#rulename").val()), //名称
                        author: $.trim($("#person").val()), //创建人
                        ruleattributes: $("#ruleattributes").val(),//规则属性
                        status: $("#state").val(),//状态
                        create_time: $("#start").val(),//创建开始日期
                        create_time_end: $("#end").val(), //创建结束日期
                        publish_time: $("#startS").val(), //上线开始日期
                        publish_time_end: $("#endS").val(), //上线结束日期
                        end_time: $("#startUp").val(), //更新开始日期
                        end_time_end: $("#endUp").val(), //更新结束日期
                        sign_default_score:$("#scoreFlag").val()
//                        fatal: $("#rulefatal").val()
                    };
                    return temp;
                },
                responseHandler: function (res) {
                    tools.tableData = res.data;
                    if (!res.data) {
                        return {
                            "total": 0,//总页数
                            "rows": []   //数据
                        };
                    } else {
                        return {
                            "total": res.data.total,//总页数
                            "rows": res.data.rows   //数据
                        };
                    }

                },
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: true,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: [
                    {
                        checkbox: true, // 显示一个勾选框
                        align: 'center' // 居中显示
                    },
                    {
                        align: "center",
                        halign: "center",
                        title: '序号',//标题  可不加
                        // width: 60,
                        field: 'number',
                        formatter: function (value, row, index) {
                            var getOptions = $("#myTable").bootstrapTable('getOptions');
                            var pagenum = getOptions.pageNumber;
                            var pagesize = getOptions.pageSize;
                            var st = (pagenum - 1) * pagesize;
                            return (st + index + 1) + "";
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'rulename',
                        sortable: true,
                        title: '规则名称'
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'ruleattributes',
                        sortable: true,
                        title: '规则属性',
                        formatter: function (value, row, index) {
                            return bs.changeState(value, tools.ruleattributesArr);
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'ruleclassify',
                        sortable: true,
                        title: '规则分类'
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'author',
                        sortable: true,
                        title: '创建人',
//                        visible: false
                    },

                    {
                        align: "center",
                        halign: "center",
                        field: 'status',
                        title: '发布状态',
                        sortable: true,
                        width: 60,
                        formatter: function (value, row, index) {
                            var str = "";
                            var color = "#000";
                            if (value == "1") {
                                color = "stateGreen";
                            }
                            str = bs.changeState(value, tools.stateArr);
                            return "<span class='" + color + "'>" + str + "</span>";
                        }
                    },
                    {
                        align: "center",
                        halign: "center",
                        field: 'publish_time',
                        sortable: true,
                        title: '上线时间'
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'end_time',
                        sortable: true,
                        title: '更新时间'

                    }, {
                        align: "center",
                        halign: "center",
                        field: 'fatal',
                        sortable: true,
                        title: '致命性',
                        formatter: function (value, row, index) {
                            if(row.sign_default_score == 1) {
                                return ''
                            }else{
                                return bs.changeState(value, tools.fatalArr);
                            }
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'default_score',
                        sortable: true,
                        title: '建议分值',
                        formatter: function (value, row, index) {
                            if(value!=null){
                                if(row.sign_default_score==-1){
                                    value="-"+value;
                                }
                            }
                            return value;
                        }
                    }, {
                        align: "center",
                        halign: "center",
                        field: 'notes',
                        title: '备注'
                    }
                ],

                onLoadSuccess: function (data) {  //加载成功时执行
                    resize.me(1);
                    if (!data.total || data.total == 0) {
                        var src = basePath + "/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                },
                onExpandRow: function (index, row, $detail) {
                    //这一步就是相当于在当前点击列下新创建一个table
                    $.ajax({
                        url: tools.ruleUrl + "/combinationRule/getcombinationRulebyid",
                        type: "post",
                        data: {
                            "idcombinationRule": row.idcombinationrule
                        },
                        async: false,
                        success: function (result) {
                            var code = result.code;
                            var data = result.data;
                            if (code) {
                                if (data) {
                                    var textId = data.text;
                                    var volumeId = data.volume;
                                    var voiceSpeedId = data.voicespeed;
                                    var grabId = data.grab;//强插话
                                    var channelsId = data.channels;
                                    var muteId = data.mute;
                                    var negativeId = data.negative;
                                    var arr = [];
                                    var ruleobj;
                                    if (textId) {
                                        var textIdArr = textId.split(",");
                                        $.each(textIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("文本", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    if (volumeId) {
                                        var volumeIdArr = volumeId.split(",");
                                        $.each(volumeIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("音量", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    if (voiceSpeedId) {
                                        var voiceSpeedIdArr = voiceSpeedId.split(",");
                                        $.each(voiceSpeedIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("语速", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    if (grabId) {
                                        var grabIdArr = grabId.split(",");
                                        $.each(grabIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("抢插话", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    if (channelsId) {
                                        var channelsIdArr = channelsId.split(",");
                                        $.each(channelsIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("声道", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });

                                    }
                                    if (muteId) {
                                        var muteIdArr = muteId.split(",");
                                        $.each(muteIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("静音", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    if (negativeId) {
                                        var negativeIdArr = negativeId.split(",");
                                        $.each(negativeIdArr, function (index, value) {
                                            ruleobj = rule.getRuleOne("负面情绪", value);
                                            if (ruleobj) {
                                                arr.push(ruleobj);
                                            }
                                        });
                                    }
                                    row.arr = arr.sort(bs.sortBy("number"));
                                }
                                InitSubTable2(index, row, $detail);
                            }
                        }
                    });

                },
            });
        };
        //初始化子表格(无线循环)
        InitSubTable2 = function (index, row, $detail) {
            var parentid = row.idcombinationrule;
            var cur_table = $detail.html('<table></table>').find('table');
            $(cur_table).bootstrapTable({
                data: row.arr,
                queryParams: {strParentID: parentid},
                ajaxOptions: {strParentID: parentid},
                clickToSelect: true,
                uniqueId: "id",
                pageSize: 10,
                pageList: [10, 25],
                columns: rule.columnsSubRule(),
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        var src = basePath + "/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });
        };
        return oTableInit;
    };
    var TableInit1 = function ($elem) {
        var oTableInit1 = new Object();
        //初始化Table
        oTableInit1.Init = function ($elem, jsonData) {
            $elem.bootstrapTable('destroy');
            $elem.bootstrapTable({
                data: jsonData,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
//                sortable: true,                     //是否启用排序
//                sortName: "number", //排序方式
//                sortOrder: "desc",
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: false,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: rule.columnsSubRule("has"),
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        var src = basePath + "/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });

        }
        return oTableInit1;
    };
    //    标准问
    var TableInit2 = function ($elem) {
        var oTableInit2 = new Object();
        //初始化Table
        oTableInit2.Init = function ($elem, jsonData) {
            $elem.bootstrapTable('destroy');
            $elem.bootstrapTable({
                data: jsonData,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
//                sortable: true,                     //是否启用排序
//                sortName: "number", //排序方式
//                sortOrder: "desc",
                sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: [
                    {
                        title: '序号',//标题  可不加
                        field: 'number',
                        width: 60,
                        formatter: function (value, row, index) {
                            return (index + 1) + "";
                        }
                    },
                    {
                        field: 'abstract',
                        title: '问题'
                    }
                ],
                onClickRow: function (row, elem) {
                    $('.info').removeClass('info');
                    $(elem).addClass('info');
                    var id = row.kbdataid;
                    $("#text").html(row.abstract).attr("data-id", id);
                    $.ajax({
                        url: tools.ruleUrl + "/kbdata/getKMQueryManage",
                        type: "post",
                        data: {
                            "city": $("#textPro").attr("data-code"),
                            "kbdataid": id
                        },
                        async: false,
                        success: function (result) {
                            var code = result.code;
                            var data = result.data;
                            if (code) {
                                var oTable3 = new TableInit3();
                                oTable3.Init($("#customTable"), data);
                            } else {
                                toastrCog.error(result.message, 1000);
                            }
                        }
                    });

                },
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        var src = basePath + "/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });

        }
        return oTableInit2;
    };
    //   客户问
    var TableInit3 = function ($elem) {
        var oTableInit3 = new Object();
        //初始化Table
        oTableInit3.Init = function ($elem, jsonData) {
            $elem.bootstrapTable('destroy');
            $elem.bootstrapTable({
                data: jsonData,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
//                sortable: true,                     //是否启用排序
//                sortName: "number", //排序方式
//                sortOrder: "desc",
                sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
//                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: false,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: [
                    {
                        title: '序号',//标题  可不加
                        field: 'number',
                        width: 60,
                        formatter: function (value, row, index) {
                            return (index + 1) + "";
                        }
                    },
                    {
                        field: 'query',
                        title: '问题'
                    }
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        var src = basePath + "/assert/image/nodata.png";
                        $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
                    var src = basePath + "/assert/image/nodata.png";
                    $(".no-records-found").find("td").html('<img src="' + src + '" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }
            });

        }
        return oTableInit3;
    };
    var menu = {
        init: function () {
            menu.render($("#jstree"));
        },
        render: function (elem) {
            var jstree = elem;
            jstree.jstree("destroy");
            jstree.data('jstree', false).empty();
            jstree.jstree({
                "core": {
                    "animation": false,
                    "multiple": false,
                    "check_callback": true,
                    'data': function (obj, callback) {
                        $.ajax({
                            type: "POST",
                            url: tools.ruleUrl + '/service/listservicebyidparent',
//                            dataType: "json",
                            data: {
                                idparent: $("#idservice").val()
                            },
                            success: function (data) {
                                var result = data.data;
                                if (result != null) {
                                    var arr = [];
                                    for (var i = 0; i < result.length; i++) {
                                        var obj = {};
                                        var id = result[i].idservice;
                                        var name = result[i].service;
                                        var parentid = result[i].idparent;
                                        var province = result[i].province;
                                        var notes = result[i].notes;
                                        obj.id = id;
                                        obj.text = name;
                                        obj.children = [];
                                        obj.parentid = parentid;
                                        obj.province = province;
                                        obj.notes = notes;
                                        arr.push(obj);
                                    }
                                    var arr1=[];
                                    if($("#idservice").val()!=1){//如果是省份人员进来
                                        arr1 = menu.rootLoopMenu(arr,1);
                                        callback.call(this, menu.loopMenu(arr1));
                                    }else{
                                        arr1 = menu.rootLoopMenu(arr);
                                        callback.call(this, menu.loopMenu(arr1[0].children));
                                    }
                                }
                                menu.changeMenu(elem);
                                menu.search(elem);
                            }
                        });
                    }
                },
                "types": {
                    "default": {
                        "icon": "jstree-folder"
                    },
                    "html": {
                        "icon": "jstree-file"
                    }
                },
                "plugins": ["types", "search", "unique", "contextmenu"],
                'contextmenu': {
                    'items': menu.customMenu     //每个节点都会调用这个函数
                }
            }).bind('loaded.jstree', function (e, data) {
                jstree.jstree("deselect_all", true);
                $("li[aria-selected='true']").click();
            });
        },
        delMenu: function (id) {
            $.ajax({
                type: "post",
                url: tools.ruleUrl + '/service/deleteservicebyid',
                dataType: "json",
                data: {
                    idservice: $("#delModalCon").attr("data-id")
                },
                success: function (result) {
                    var msg = result.message;
                    if (result.code == 0) {
                        toastrCog.error(msg, 3000)
                    } else {
                        $("#classify").val("").attr("data-id", "");
                        menu.render($("#jstree"));
                        toastrCog.success(msg, 1000);
                        $("#myTable").bootstrapTable('refresh');
                    }
                }
            });

        },
        customMenu: function (node) {
            var items = {
                'add': {
                    'label': '新增分类',
                    'action': function (data) {
                        var inst = $.jstree.reference(data.reference),
                            obj = inst.get_node(data.reference);
                        var provincecode = obj.original.province;
                        var id = obj.original.id;
                        var parentid = obj.original.parentid;
                        $("#addTypeForm")[0].reset();
                        $("#addTypeModal").modal("show");
                        $("#addTypeModal").attr("data-code", "add");
                        $("#addTypeForm").find(".modal-title").html("添加分类");
                        $("#addTypeModal").attr("data-id", id);
                        $("#proTypeModal").prop("disabled", true);
                        tools.updataSelect($("#proTypeModal"), provincecode);
                        $("#proTypeModalAddInput").val(provincecode);
                        if(parentid==1){
                            $("#typeParentModal").parents(".form-group").addClass("hidden");
                        }else{
                            $("#typeParentModal").val(obj.text).attr({"readonly":true,"data-id":id});
                            $("#typeParentModal").parents(".form-group").removeClass("hidden");
                        }

                    }
                },
                'addModel': {
                    'label': '添加规则',
                    'action': function (data) {
                        $("#btnAdd").click();
                    }
                },
                'edit': {
                    'label': '编辑',
                    'action': function (data) {
                        var inst = $.jstree.reference(data.reference),
                            obj = inst.get_node(data.reference);
                        $("#addTypeModal").modal("show");
                        $("#addTypeModal").attr("data-code", "edit");
                        $("#addTypeForm").find(".modal-title").html("编辑分类");
                        var provincecode = obj.original.province;
                        var parentid = obj.original.parentid;
                        $("#addTypeModal").attr({"data-id": Math.abs(obj.id), "data-parentid": parentid});
                        $("#proTypeModal").prop("disabled", true);
                        tools.updataSelect($("#proTypeModal"), provincecode);
                        $("#proTypeModalAddInput").val(provincecode);
                        $("#modelTypeName").val(obj.text);
                        $("#remarkTypeAdd").val(obj.original.notes);
                    }
                },
                'delete': {
                    'label': '删除',
                    'action': function (data) {
                        var inst = $.jstree.reference(data.reference),
                            obj = inst.get_node(data.reference);
                        $("#delModalCon").modal("show").attr("data-id", obj.original.id);
                        $("#delNameCon").html(obj.text).css("color", "rgb(50, 136, 226)");
                    }
                }

            };

            var code = menu.checkData(node.id);
            if (code == 0) {
                delete items.edit;  //如果是省份 删除编辑方法
                delete items.addModel;  //如果是省份 删除编辑方法
                delete items.delete;  //如果是省份 删除编辑方法
            }
            if (code == 1) { //只能添加规则
                delete items.add;  //删除添加分类方法
            }
            if (code == 2) { //只能添加业务树节点
                delete items.addModel;  //如果是省份 删除新增模型方法
            }
            return items;
        },
        checkData: function (id) {
            var msg = "";
            var params = {"idservice": id};
            $.ajax({
                type: "POST",
                url: tools.ruleUrl + '/service/isaddcombrule',
                dataType: "json",
                data: params,
                async: false,
                success: function (result) {
                    msg = result.data;
                }
            });
            return msg;
        },
        rootLoopMenu: function (data, parent) {
            var tree = [];
            var temp;
            for (var i = 0; i < data.length; i++) {
                var obj = data[i];
                if (data[i].parentid == parent) {
                    temp = menu.rootLoopMenu(data, data[i].id);
                    if (temp.length > 0) {
                        obj.children = temp;
                    }
                    tree.push(obj);
                }
            }
            return tree;
        },
        loopMenu: function (array) {
            if (array && array.length > 0) {
                for (var i = 0; i < array.length; i++) {
                    var children = array[i]["children"];
                    if (children.length <= 0) {
                        array[i].type = "html"
                    } else {
                        array[i].state = {"opened": "true"}
                    }
                    if (children) {
                        menu.loopMenu(children);
                    }
                }
                return array;
            } else {
                return []
            }
        },
        changeMenu: function (elem) {
            elem.unbind("changed.jstree").on("changed.jstree", function (e, data) {
                var val = data.selected;
                var selectNode = elem.jstree("get_node", data.selected);
                if (elem.attr("id") == "jstree") {
                    if (selectNode) {
                        $("#classify").val(selectNode.original.text).attr("data-id", selectNode.original.id);
                    }
                    tools.tableRefresh();
                } else if (elem.attr("id") == "jsTreeMove") {
                    if (selectNode) {
                        $("#moveRuleModel").attr("data-idservice", selectNode.original.id);
                    }
                } else if (elem.attr("id") == "jsTreeCopy") {
                    if (selectNode) {
                        $("#copyModal").attr("data-idservice", selectNode.original.id);
                        if (selectNode.original.parentid != 1 && selectNode.children.length == 0) {
                            $(".ceng").hide();
                            $(".ceng").next().show();
                        } else {
                            $(".ceng").show();
                            $(".ceng").next().hide();
                        }
                    }
                }
            });
        },
        search: function (elem) {
            elem.prev().find(".fa-search").on("click", function () {
                elem.jstree(true).search($.trim(elem.prev().find("input").val()));
                menu.scrollSearch(elem);
            });
            elem.prev().find("input").on("keyup", function (e) {
                var code = e.charCode || e.keyCode;
                if (code == 13) {
                    elem.jstree(true).search($.trim(elem.prev().find("input").val()));
                    menu.scrollSearch(elem);
                }
            })
        },
        scrollSearch: function (elem) {
            if (elem.find(".jstree-search").length > 0) {
                var odiv = elem.find(".jstree-search").eq(0)[0];
                var top = odiv.offsetTop;
                var height = odiv.offsetHeight;
                var elemTop = elem[0].scrollTop;
                //获取当前屏幕大小
                var size = elem.height();
                //加上元素本身的高度，是元素全部出现事件
                if ((top + height) < (elemTop + size) && (top + height) > elemTop) {

                } else {
                    elem.animate({scrollTop: top - 70}, "slow");
                }
            }
        }
    };
    var menuText = {
        render: function (elem, city) {
            var jstree = elem;
            jstree.jstree("destroy");
            jstree.data('jstree', false).empty();
            jstree.jstree({
                "core": {
                    "animation": false,
                    "multiple": false,
                    "check_callback": true,
                    'data': function (obj, callback) {
                        $.ajax({
                            url: tools.ruleUrl + "/kbdata/getKMService",
                            type: "post",
                            data: {
                                "city": city
                            },
                            async: false,
                            success: function (result) {
                                var code = result.code;
                                var data = result.data;
                                if (code) {
                                    var arr = [];
                                    for (var j = 0; j < data.length; j++) {
                                        var datas = data[j];
                                        for (var i = 0; i < datas.length; i++) {
                                            var obj = {};
                                            var id = datas[i].serviceid;
                                            var name = datas[i].service;
                                            var parentid = datas[i].parentid;
                                            obj.id = id;
                                            obj.text = name;
                                            obj.children = [];
                                            obj.parentid = parentid;
                                            if (obj.parentid == 0) {
                                                obj.parentid = null;
                                            }
                                            arr.push(obj);
                                        }
                                    }
                                    var arr1 = menu.rootLoopMenu(arr);
                                    callback.call(this, menuText.loopMenu(arr1));
                                    menuText.changeMenu(elem);
                                    menu.search(elem);
                                } else {
                                    toastrCog.error(result.message, 1000);
                                }
                            }
                        });
                    }
                },
                "types": {
                    "default": {
                        "icon": "jstree-folder"
                    },
                    "html": {
                        "icon": "jstree-file"
                    }
                },
                "plugins": ["types", "search", "unique"]
            }).bind('loaded.jstree', function (e, data) {
                jstree.jstree("deselect_all", true);
                $("li[aria-selected='true']").click();
            });
        },
        changeMenu: function (elem) {
            elem.on("changed.jstree", function (e, data) {
                var val = data.selected;
                var selectNode = elem.jstree("get_node", data.selected);
                console.log(selectNode)
                if(selectNode.id == "1863145"){
                    toastrCog.error('请选择子节点！',2000)
                }else{
                    tools.loading($("#standardTable"));
                    $.ajax({
                        url: tools.ruleUrl + "/kbdata/getKMAbstract",
                        type: "post",
                        data: {
                            "city": $("#textPro").attr("data-code"),
                            "serviceid": selectNode.id
                        },
                        success: function (result) {
                            var code = result.code;
                            var data = result.data;
                            if (code) {
                                $("#standardTable").bootstrapTable('load', data);
                                $("#customTable").bootstrapTable('load', []);
                            } else {
                                toastrCog.error(result.message, 1000);
                            }
                        }
                    });
                }
            });
        },
        loopMenu: function (array) {
            if (array && array.length > 0) {
                for (var i = 0; i < array.length; i++) {
                    var children = array[i]["children"];
                    if (children.length <= 0) {
                        array[i].type = "html"
                    }
                    array[i].state = {"opened": false};
                    if (children) {
                        menuText.loopMenu(children);
                    }
                }
                return array;
            } else {
                return []
            }
        },
    };
    var resize = {
        init: function () {
            resize.me(1);
            $(window).resize(function () {
                resize.me();
            })
        },
        me: function (one) {
            var winW = $(window).width();
            var winH = $(window).height();
            $(".ibox").width(winW-20);
            $(".ibox").height(winH - 25);
            $("#jstree").height(winH - 60);
            $(".model_right").width(winW - 240);
            bs.autoTableHeight($('#myTable'),winH -$(".tools_bar").height()-22-$(".search").height())
            // $(".model_right .fixed-table-body").css("maxHeight", (winH - $(".tools_bar").height() - 15 - $(".search").height() - 35 - $(".model_right .clearfix").height()) + "px");
        }
    };
    var tools = {
        ruleUrl: "",
        tableData: [],
        ruleTableData: [],
        classifyArr: [],
        stateArr: [],
        seatIdArr: [],
        seatAllArr: [],
        proArr: [],//存放省份信息
        posArr: [
            {name: "请选择", value: ""},
            {name: "大于等于", value: "大于等于"},
            {name: "小于等于", value: "小于等于"},
            {name: "录音结尾", value: "录音结尾"}
        ],//用来存绝对位置
        rosObjArr: [{name: "请选择", value: ""}],
        rosArr: [
            {name: "前", value: "0"},
            {name: "后", value: "1"},
            {name: "前后", value: "2"}
        ],
        speechArr: [
            {name: "请选择", value: ""},
            {name: "坐席", value: "0"},
            {name: "客户", value: "1"},
            {name: "全部", value: "2"}
        ],
        isHitArr: [
            {name: "是", value: "1"},
            {name: "否", value: "0"}
        ],
        typeArr: [
            {name: "text", value: "文本"},
            {name: "mute", value: "静音"},
            {name: "volume", value: "音量"},
            {name: "voicespeed", value: "语速"},
            {name: "negative", value: "负面情绪"},
            {name: "grab", value: "抢插话"},
            {name: "channels", value: "声道"}
        ],
        ruleattributesArr: [],
        fatalArr: [],
        maxTextLength: null,
        scoreFlagArr:[],//用来存放分值属性状态
        init: function () {
            tools.getConfig();//获取规则管理路径前缀
            tools.getProTreeId();//获取规则管理左侧树根节点id
            tools.selectInit();
            tools.tabSearch();
            tools.enterSearch();
            tools.search();
            tools.reset();
            tools.refresh();
            tools.addModel();
            tools.editModel();
            tools.saveModel();
            tools.delModel();
            tools.startModel();
            tools.stopModel();
            tools.copyModel();
            tools.moveModel();
            $("#addModal").on("hidden.bs.modal", function () {
                var form = $("#addModelForm");
                tools.hideLabel(form, '#testName');
                tools.hideLabel(form, '#scoreAdd');
            });
            $("#addTypeModal").on("hidden.bs.modal", function () {
                var form = $("#addTypeForm");
                tools.hideLabel(form, '#proTypeModalAddInput');
                tools.hideLabel(form, '#modelTypeName');
            });
            $(".form-horizontal").on("click", "#radio_box input", function () {
                $(this).prop("checked", true);
                $(this).siblings("input").prop("checked", false);
            })

        },
        loading:function($elem){
            var loadHtml=$('<div class="loaded" style="margin:0 auto">' +
                '<div class="loader">' +
                '<div class="loader-inner line-scale-pulse-out">' +
                '<div></div>' +
                '<div></div>' +
                '<div></div>' +
                '<div></div>' +
                '<div></div>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '<div>请稍等，数据正在加载中...</div>');
            $elem.find("tbody tr").remove();
            $elem.find("tbody").append('<tr class="no-records-found"><td style="width:100%" colspan="10"></td></tr>');
            $elem.find("tbody td").html(loadHtml.html());
        },
        hideLabel: function (form, input) {
            form.jqxValidator('hideHint', input);
        },
        getConfig: function () {
            tools.ruleUrl = bs.getSysConfig("GZGL_URL").value;
            var maxNum = bs.getSysConfig("NAME_LIMIT");
            var num = 50;
            if (maxNum.value) {
                num = maxNum.value
            }
            tools.maxTextLength = num;
        },
        selectInit: function () {
            bs.dataTime("#start", "#end", "YYYY-MM-DD");
            bs.dataTime("#startS", "#endS", "YYYY-MM-DD");
            bs.dataTime("#startUp", "#endUp", "YYYY-MM-DD");
            tools.selectProvince();
            tools.getState();
            tools.getScoreFlag();
            tools.getRuleattributes();
            tools.getFatal();
            bs.selectDown($("#modelTypeEdit"), tools.classifyArr, "", '100%');
            bs.selectDown($("#tagTypeCopy"), tools.classifyArr, "", "100%");
            tools.selectChange($("#proTypeModal"), $("#proTypeModalAddInput"));
            tools.selectChange($("#typeModal"), $("#typeModalAddInput"));
            tools.selectChange($("#modelTypeEdit"), $("#typeModalEditInput"));
            tools.selectChange($("#proTypeModalCopy"), $("#proTypeModalAddInputCopy"));
            tools.selectChange($("#tagTypeCopy"), $("#tagTypeAddInputCopy"));
            bs.selectDown($(".absolutePos"), tools.posArr, "", "100px");
            bs.selectDownNoDisabled($(".relativeObj"), tools.rosObjArr, "", "100px");
            bs.selectDownNoDisabled($(".relativePos"), tools.rosArr, "", "100px");
            bs.selectDown($(".speechP"), tools.speechArr, "", "100px");
            bs.selectDown($(".hitP"), tools.isHitArr, "", "100px");
            $(".absolutePos").on("change", function (event, sel) {
                if (sel.selected !== "") {
                    $(this).next().nextAll().show();
                } else {
                    $(this).next().nextAll().hide();
                }
            });
            $(".relativeObj").on("change", function (event, sel) {
                var elem = $(this).parents(".formSubBox").find(".relativePos");
                var next= elem.next();
                if (sel.selected != "") {
                    next.nextAll().show();
                    elem.next(".chosen-container").show();
                } else {
                    next.nextAll().hide();
                    elem.next(".chosen-container").hide();
                }

            });

            $("#proTypeModalCopy").on("change", function (event, sel) {//根据省份渲染分类信息
                if (sel.selected !== "") {
                    $("#tagTypeAddInputCopy").val("");
                }
            });
            $("#boxAdd input[name='scoreFlag']").on("click", function () {
                if ($(this).val() == -1) {
                    $("#fatalAdd").val(1).attr("disabled", false).trigger('chosen:updated');
                } else {
                    $("#fatalAdd").val(0).attr("disabled", true).trigger('chosen:updated');
                }
            })
            $("#boxEdit input[name='scoreFlagEdit']").on("click", function () {
                if ($(this).val() == -1) {
                    $("#fatalEdit").val(1).attr("disabled", false).trigger('chosen:updated');
                } else {
                    $("#fatalEdit").val(0).attr("disabled", true).trigger('chosen:updated');
                }
            })
        },
        hideAddHints: function () {
            var form = $("#addModelForm");
            form.jqxValidator('hideHint', "#ruleNameAdd");
            form.jqxValidator('hideHint', "#scoreAdd");
        },
        hideEditHints: function () {
            var form = $("#editForm");
            form.jqxValidator('hideHint', "#ruleNameEdit");
            form.jqxValidator('hideHint', "#scoreAddEdit");
        },
        getProTreeId: function () {
            $.ajax({
                url: tools.ruleUrl + "/service/getservicebyprovince",
                type: "post",
                data: {
                    "province": $("#spanId",parent.document).attr("data-procode")
                },
                async: false,
                success: function (result) {
                    var code = result.code;
                    var data = result.data;
                    if (code) {
                        $("#idservice").val(data.idservice);
                    }
                }
            });
        },
        selectChange: function ($elem, $input) {
            $elem.on("change", function (event, sel) {
                $input.val(sel.selected);
                if (sel.selected == "") {
                    $input.next().html("").css("display", "none !important");
                }
            });
        },
        getState: function () {
            tools.stateArr = bs.getDownData("sys_post_status");
            tools.stateArr.shift();
            tools.stateArr.unshift({"name": "请选择", "value": ""});
            bs.selectDown($("#state"), tools.stateArr);
        },
        getScoreFlag: function () {
            tools.scoreFlagArr = bs.getDownData("score_flag");
            tools.scoreFlagArr.shift();
            tools.scoreFlagArr.unshift({"name": "请选择", "value": ""});
            bs.selectDown($("#scoreFlag"), tools.scoreFlagArr);
        },
        getRuleattributes: function () {
            tools.ruleattributesArr = bs.getDownData("rule_property");
            tools.ruleattributesArr.shift();
            tools.ruleattributesArr.unshift({"name": "请选择", "value": ""});
            bs.selectDown($("#ruleattributes"), tools.ruleattributesArr);
            bs.selectDown($("#ruleAttrAdd"), tools.ruleattributesArr, "", "100%");
            bs.selectDown($("#ruleAttrEdit"), tools.ruleattributesArr, "", "100%");
        },
        getFatal: function () {
            tools.fatalArr = bs.getDownData("rule_nature");
            tools.fatalArr.shift();
//            tools.fatalArr.unshift({"name": "请选择", "value": ""});
            bs.selectDown($("#rulefatal"), tools.fatalArr);
            bs.selectDown($("#fatalAdd"), tools.fatalArr, "", "100%");
            bs.selectDown($("#fatalEdit"), tools.fatalArr, "", "100%");
        },
        changeState: function (value) {
            var str = "";
            for (var i = 0; i < tools.stateArr.length; i++) {
                if (value == tools.stateArr[i].value) {
                    str = tools.stateArr[i].name
                }
            }
            return str;
        },
        tabSearch: function () {
            var search = $(".search");
            $("#btnSearch").on("click", function () {
                if (search.hasClass("on")) {
                    search.slideUp();
                    search.removeClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 查询').attr("title", "显示查询条");
                } else {
                    search.slideDown();
                    search.addClass("on");
                    $("#btnSearch").html('<i class="fa fa-filter"></i> 隐藏').attr("title", "隐藏查询条");
                }

            });
        },
        search: function () {
            $("#search").on("click", function () {
                tools.tableRefresh();
            });
            $("#searchAll").on("click", function () {
                $("#classify").val("").attr("data-id", $("#idservice").val());
                $("#jstree").jstree("deselect_all", true);
                tools.tableRefresh();
            });

        },
        tableRefresh: function () {
            $("#myTable").bootstrapTable('refreshOptions', {pageNumber: 1});
            $("#myTable").bootstrapTable('refresh');
        },
        enterSearch: function () {
            $("body").on("keyup", function (e) {
                var code = e.charCode || e.keyCode;
                if (code == 13) {
                    //此处编写用户敲回车后的代码
                    tools.tableRefresh();
                }
            })
        },
        reset: function () {
            $("#reset").on("click", function () {
                bs.resetSearch($(".search"), ["classify"]);
                if ($("#laydate_box").length > 0) {
                    bs.resetTimeElems("#start", "#end", "#startS", "#endS", "#startUp", "#endUp");
                }
                tools.tableRefresh();
            })
        },
        resetSelect: function ($obj) {
            $obj.val("");
            $obj.trigger("chosen:updated");
        },
        refresh: function () {
            $("#refresh").on("click", function () {
                tools.tableRefresh();
            })
        },
        selectProvince: function () {//省份下拉框初始化
            tools.proArr = bs.getProvince();
            var arr = tools.proArr;
            arr.shift();
            arr.unshift({name: "请选择", value: "", id: ""});
            bs.selectDown($("#proTypeModal"), arr, "", "100%");
        },
        getSeatId: function () {//获取创建人数据
            var arr = bs.getGreatPerson("/rest/searchUser/searchModelUser", "userName");
            $("#person").autocomplete({
                source: arr
            });
            tools.seatAllArr = bs.getGreatPerson("/rest/searchUser/searchModelUser", "");
        },
        addModel: function () {
            $("#btnAdd").unbind("click").on("click", function () {
                tools.hideAddHints();
                var ref = $('#jstree').jstree(true);//获得整个树
                var sel = ref.get_selected(); //获得所有选中节点，返回值为数组
                var node = $('#jstree').jstree("get_node", sel);
                var parentid="";
                var pro="";
                if(node){
                    parentid = node.original.parentid;
                    pro= node.original.province;
                    if (parentid == 1) {
                        toastrCog.error("请选择一个分类", 3000);
                        return
                    }
                    $("#boxAdd").show().attr({"data-pro":pro,"data-id":""});
                    $(".ruleAllBox").show();
                    $("#box").hide();
                    $("#boxEdit").hide();
                    $("#addModelForm")[0].reset();
                    $("#addModelForm").next().hide();
                    $("#ruleNameAdd").attr("data-val", "");
                    $("#ruleClassifyAdd").val(node.original.text).attr("data-id", node.original.id);
                    $("#ruleAttrAdd").val("0").trigger("chosen:updated");
                    $("#ruleAttrAdd").attr("disabled",false).trigger("chosen:updated");
                    $("#fatalAdd").val("1").attr("disabled",false).trigger("chosen:updated");
                    rule.subRuleList = [];
                    tools.rootRuleData(rule.subRuleList, $("#boxAdd").find("table"));
                    $("#boxAdd").find(".resetRule").click();
                    $("#boxAdd").find(".tabTitle span").eq(0).click();
                }else{
                    toastrCog.error("请选择一个分类", 3000);
                }
            })
        },
        saveModel: function () {
            $("#save").on("click", function () {
                $("#addModelForm").jqxValidator("validate");
            });
            $("#addModelForm").on("validationSuccess", function () {
                var scoreFlag = $("#boxAdd input[name='scoreFlag']:checked").val();
                var default_score = $("#scoreAdd").val();
                if (scoreFlag == 0 && default_score != "") {//如果选择的减分就 default_score 就为负值
                    default_score = "-" + default_score;
                }
                $.ajax({
                    url: tools.ruleUrl + "/combinationRule/addcombinationRule",
                    type: "post",
                    data: JSON.stringify({
                        author: $("#spanId", parent.document).attr("title"),
                        idauthor: $("#spanId", parent.document).attr("data-userid"),
                        default_score: default_score,
                        fatal: $("#fatalAdd").val(),
                        notes: $("#remarkAdd").val(),
                        ruleattributes: $("#ruleAttrAdd").val(),
                        ruleclassify: $("#ruleClassifyAdd").val(),
                        rulename: $("#ruleNameAdd").val(),
                        idcombinationrule: $("#boxAdd").attr("data-id"),
                        idservice: $("#classify").attr("data-id"),
                        status: 0,
                        sign_default_score:$("input[name='scoreFlag']:checked").val()
                    }),
                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                    success: function (result) {
                        var msg = result.message;
                        if (result.code) {
                            tools.tableRefresh();
                            $("#ruleNameAdd").attr("data-val", $("#ruleNameAdd").val());
                            if ($("#ruleAttrAdd").val() == "0") {//如果是系统才会添加子规则
                                if ($("#boxAdd").attr("data-id")) {
                                    $("#boxAdd").hide();
                                    $("#boxEdit").hide();
                                    $("#boxAdd").parent().hide();
                                    $("#box").show();
                                }
                                $("#boxAdd").attr("data-id", result.data);
                                $("#addModelForm").next().show();
                            } else {
                                $("#boxAdd").hide();
                                $("#boxEdit").hide();
                                $("#boxAdd").parent().hide();
                                $("#box").show();
                            }
                            toastrCog.success(msg, 1000);
                            $("#ruleAttrAdd").attr("disabled",true).trigger("chosen:updated");
                        } else {
                            toastrCog.error(msg, 3000)
                        }
                    }
                });
            });
        },
        editModel: function () {
            $("#editModal").on("hide.bs.modal", function () {
                rule.subRuleList = [];
            });
            $("#editModal").on("show.bs.modal", function () {
                rule.subRuleList = [];
            });
            $("#btnEdit").on("click", function () {
                tools.hideEditHints();
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要编辑的数据！", 3000);
                } else if (selectArr.length > 1) {
                    toastrCog.error("请选择一条要编辑的数据！", 3000);
                } else if (selectArr[0].status == 1) {
                    toastrCog.error("规则已上线，无法编辑。要编辑规则,请先下线规则。", 3000);
                } else {
                    var ref = $('#jstree').jstree(true);//获得整个树
                    var sel = ref.get_selected(); //获得所有选中节点，返回值为数组
                    var node = $('#jstree').jstree("get_node", sel);
                    var pro = node.original.province;
                    $("#boxEdit").show();
                    $(".ruleAllBox").show();
                    $("#boxAdd").hide();
                    $("#box").hide();
                    $("#ruleNameEdit").val(selectArr[0].rulename).attr("data-val", selectArr[0].rulename);
                    $("#ruleAttrEdit").val(selectArr[0].ruleattributes).attr({"disabled": true}).trigger("chosen:updated");
                    $("#ruleClassifyEdit").val(selectArr[0].ruleclassify).attr("data-id", selectArr[0].idservice);
                    $("#fatalEdit").val(selectArr[0].fatal).trigger("chosen:updated");
                    var sign_default_score=selectArr[0].sign_default_score;
                    if(sign_default_score==1){
                        $("#fatalEdit").attr("disabled",true).trigger("chosen:updated");
                    }else{
                        $("#fatalEdit").attr("disabled",false).trigger("chosen:updated");
                    }
                    var default_score=selectArr[0].default_score;
                    if(default_score!=null){
                        default_score=Math.abs(selectArr[0].default_score)
                    }else{
                        default_score=""
                    }
                    $("#scoreEdit").val(default_score);
                    $("#remarkEdit").val(selectArr[0].notes);
                    $("#boxEdit input[name='scoreFlagEdit'][value='"+selectArr[0].sign_default_score+"']").prop("checked",true);
                    $("#boxEdit").attr({"data-id": selectArr[0].idcombinationrule, "data-pro": pro});
                    if ($("#ruleAttrEdit").val() == "0") {//规则属性是系统时 显示添加子规则模块
                        $("#editForm").next().show();
                        $("#boxEdit .tabTitle span").eq(0).click();
                        $("#boxEdit").find(".resetRule").click();
                        $.ajax({
                            url: tools.ruleUrl + "/combinationRule/getcombinationRulebyid",
                            type: "post",
                            data: {
                                "idcombinationRule": selectArr[0].idcombinationrule
                            },
                            async: false,
                            success: function (result) {
                                var code = result.code;
                                var data = result.data;
                                if (code) {
                                    var textId = data.text;
                                    var volumeId = data.volume;
                                    var voiceSpeedId = data.voicespeed;
                                    var grabId = data.grab;//强插话
                                    var channelsId = data.channels;
                                    var muteId = data.mute;
                                    var negativeId = data.negative;
                                    var arr = [];
                                    var ruleObj;
                                    if (textId) {
                                        var textIdArr = textId.split(",");
                                        $.each(textIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("文本", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    if (volumeId) {
                                        var volumeIdArr = volumeId.split(",");
                                        $.each(volumeIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("音量", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    if (voiceSpeedId) {
                                        var voiceSpeedIdArr = voiceSpeedId.split(",");
                                        $.each(voiceSpeedIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("语速", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    if (grabId) {
                                        var grabIdArr = grabId.split(",");
                                        $.each(grabIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("抢插话", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    if (channelsId) {
                                        var channelsIdArr = channelsId.split(",");
                                        $.each(channelsIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("声道", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });

                                    }
                                    if (muteId) {
                                        var muteIdArr = muteId.split(",");
                                        $.each(muteIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("静音", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    if (negativeId) {
                                        var negativeIdArr = negativeId.split(",");
                                        $.each(negativeIdArr, function (index, value) {
                                            ruleObj = rule.getRuleOne("负面情绪", value);
                                            if (ruleObj) {
                                                arr.push(ruleObj);
                                            }
                                        });
                                    }
                                    rule.subRuleList = arr.sort(bs.sortBy("number"));
                                    rule.renderRePosObj();
                                    tools.rootRuleData(rule.subRuleList, $("#ruleEditModelForm .subTable"));
                                }
                            }
                        });
                    } else {
                        $("#editForm").next().hide();
                    }

                }
            });
            $("#saveEdit").on("click", function () {
                $("#editForm").jqxValidator("validate");
            });
            $("#editForm").on("validationSuccess", function (event) {
                var id = $("#editModal").attr("data-id");
                var scoreFlag = $("#boxEdit input[name='scoreFlagEdit']:checked").val();
                var default_score = $("#scoreEdit").val();
                $.ajax({
                    url: tools.ruleUrl + "/combinationRule/addcombinationRule",
                    type: "post",
                    data: JSON.stringify({
                        author: $("#spanId", parent.document).attr("title"),
                        idauthor: $("#spanId", parent.document).attr("data-userid"),
                        default_score: default_score,
                        fatal: $("#fatalEdit").val(),
                        notes: $("#remarkEdit").val(),
                        ruleattributes: $("#ruleAttrEdit").val(),
                        ruleclassify: $("#ruleClassifyEdit").val(),
                        rulename: $("#ruleNameEdit").val(),
                        idcombinationrule: $("#boxEdit").attr("data-id"),
                        idservice: $("#classify").attr("data-id"),
                        status: 0,
                        sign_default_score:scoreFlag
                    }),
                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                    success: function (result) {
                        var msg = result.message;
                        if (result.code) {
                            $("#box").show();
                            $(".ruleAllBox").hide();
                            $("#boxEdit").hide();
                            $("#boxAdd").hide();
                            tools.tableRefresh();
                            toastrCog.success(msg, 1000);
                        } else {
                            toastrCog.error(msg, 3000)
                        }
                    }
                });
            });

        },
        rootRuleData: function (ruleArr, $elem) {
            var oTable1 = new TableInit1();
            oTable1.Init($elem, ruleArr);
        },
        delModel: function () {
            $("#btnDel").on("click", function () {
                $("#delModal .tipBox").html('');
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                var delArr = [];//用来存放已上线数据
                var delTaskArrUp = [];//用来存放被模型（已上线）使用的数据
                var delTaskArrNo = [];//用来存放被模型（未上线）使用的数据
                for (var i = 0; i < selectArr.length; i++) {
                    if (selectArr[i].status == 1) {
                        delArr.push(selectArr[i]);//用来存放已上线数据
                    }
                }
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要删除的数据！", 3000);
                } else if (delArr.length > 0) {
                    toastrCog.error("所选数据包含已上线规则 [" + tools.getStr(delArr, "rulename") + "] ，请重新选择！", 3000);
                } else {
                    var ids = [];
                    for (var i = 0; i < selectArr.length; i++) {
                        ids.push(selectArr[i].idcombinationrule);
                    }
                    $.ajax({
                        type: "post",
                        url: tools.ruleUrl + "/combinationRule/checkModelStatus",
                        dataType: "json",
//                        contentType: 'application/json', //contentType很重要
                        data: {ids: ids.join(",")},
                        async: false,
                        success: function (data) {
                            if (data.code == 1) {
                                delTaskArrNo = data.data[1];
                            } else if (data.code == 2) {
                                delTaskArrUp = data.data[2];
                            }
                        }
                    });
                    var tipStr = "";
                    if (delTaskArrUp.length > 0) {//如果被已上线的模型使用
                        tipStr = ""
                        for (var i = 0; i < delTaskArrNo.length; i++) {
                            var obj = delTaskArrNo[i];
                            for (var key in obj) {
                                var ruleName = key;
                                var modelName = obj[key].modelName;
                                tipStr += " [" + ruleName + "] 不能删除，因为其已被模型 [" + modelName + "] 使用，并且该模型已上线。"
                            }
                        }
                        toastrCog.error(tipStr, 3000);
                    } else if (delTaskArrNo.length > 0) {//如果被未上线的模型使用
                        tipStr = "";
                        for (var i = 0; i < delTaskArrNo.length; i++) {
                            var obj = delTaskArrNo[i];
                            for (var key in obj) {
                                var ruleName = key;
                                var modelName = obj[key].modelName;
                                tipStr += "规则 [" + ruleName + "] 被模型 [" + modelName + "] 使用，"
                            }
                        }
                        $("#delModal").modal("show");
                        $("#delModal .tipBox").html(tipStr);
                        $("#delName").html("您确定要删除所选的" +
                            "<span style='color:rgb(50, 136, 226)'>" + selectArr.length + "</span>" +
                            "个规则" +
                            "<span style='color:rgb(50, 136, 226)'>" + tools.getStr(selectArr, "rulename") + "</span>吗？");
                        $("#delModal").attr("data-id", tools.getStr(selectArr, "idcombinationrule"));
                    } else {//如果规则没有被模型使用

                        var names = tools.getStr(selectArr, "rulename");
                        var ids = tools.getStr(selectArr, "idcombinationrule");
                        $("#delModal").modal("show");
                        $("#delName").html("您确定要删除所选的" +
                            "<span style='color:rgb(50, 136, 226)'>" + selectArr.length + "</span>" +
                            "个规则" +
                            "<span style='color:rgb(50, 136, 226)'>" + names + "</span>吗？");
                        $("#delModal").attr("data-id", ids);
                    }
                }
            });
            $("#delBtn").on("click", function () {
                var id = $("#delModal").attr("data-id");
                $.ajax({
                    type: "post",
                    url: tools.ruleUrl + "/combinationRule/removecombinationRulebyids",
                    dataType: "json",
//                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                    data: {
                        ids: id
                    },
                    success: function (data) {
                        if (data.code == 1) {
                            tools.tableRefresh();
                            toastrCog.success(data.message, 1000)
                        } else {
                            toastrCog.error(data.message, 3000)
                        }
                        $("#delModal").modal("hide");
                    }
                })
            });
        },
        startModel: function () {
            $("#btnStart").on("click", function () {
                $("#startModal .tipBox").html("");
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                var startArr = [];//用来存放已上线数据
                for (var i = 0; i < selectArr.length; i++) {
                    if (selectArr[i].status == 1) {
                        startArr.push(selectArr[i]);//保存已上线的数据
                    }
                }
                if (selectArr.length <= 0) {//如果没有选择数据
                    toastrCog.error("请选择要上线的数据！", 3000);
                } else if (startArr.length > 0) {//如果选择了已上线的数据
                    toastrCog.error("所选数据包含已上线规则 " + tools.getStr(startArr, "rulename") + " ，请重新选择！", 3000);
                } else {
                    var names = tools.getStr(selectArr, "rulename");
                    var ids = tools.getStr(selectArr, "idcombinationrule");
                    $("#startModal").modal("show");
                    $("#startModal .modal-title").html("上线");
                    $("#type").html(
                        "确定要上线所选的" +
                        "<span style='color:rgb(50, 136, 226)'>" + selectArr.length + "</span>" +
                        "个规则" +
                        "<span style='color:rgb(50, 136, 226)'>" + names + "</span>吗？");
                    $("#startModal").attr("data-id", ids);
                    $("#startModal").attr("data-code", 1);
                }
            });
            $("#startBtn").on("click", function () {
                $("#startBtn").html("请求中...请稍后").prop("disabled", true);
                var id = $("#startModal").attr("data-id");
                var code = $("#startModal").attr("data-code");
                $.ajax({
                    type: "post",
                    url: tools.ruleUrl + "/combinationRule/updatestatusbyids",
                    dataType: "json",
                    data: {
                        ids: id,
                        status: code
                    },
                    success: function (data) {
                        if (data.code == 1) {
                            tools.tableRefresh();
                            toastrCog.success(data.message, 1000)
                        } else {
                            toastrCog.error(data.message, 3000)
                        }
                        $("#startBtn").html("确定").prop("disabled", false);
                        $("#startModal").modal("hide");
                    }
                })
            });
        },
        stopModel: function () {
            $("#btnStop").on("click", function () {
                $("#startModal .tipBox").html("");
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                var stopArr = [];//用来存放未上线数据
                var stopTaskArrUp = [];//用来存放被已上线模型使用的数据
                var stopTaskArrNo = [];//用来存放被未上线模型使用的数据

                for (var i = 0; i < selectArr.length; i++) {
                    if (selectArr[i].status == 0) {
                        stopArr.push(selectArr[i]);//保存未上线的数据
                    }
                }
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要下线的数据！", 3000);
                } else if (stopArr.length > 0) {
                    toastrCog.error("所选的数据包含未上线的规则，请重新选择！", 2000);
                } else {
                    var ids = [];
                    for (var i = 0; i < selectArr.length; i++) {
                        ids.push(selectArr[i].idcombinationrule);
                    }
                    $.ajax({
                        type: "post",
                        url: tools.ruleUrl + "/combinationRule/checkModelStatus",
                        dataType: "json",
//                        contentType: 'application/json', //contentType很重要
                        data: {ids: ids.join(",")},
                        async: false,
                        success: function (data) {
                            if (data.code == 1) {
                                stopTaskArrNo = data.data[1];
                            } else if (data.code == 2) {
                                stopTaskArrUp = data.data[2];
                            }
                        }
                    });
                    var tipStr = "";
                    if (stopTaskArrUp.length > 0) {//如果被已上线模型使用
                        tipStr = "";
                        for (var i = 0; i < stopTaskArrUp.length; i++) {
                            var obj = stopTaskArrUp[i];
                            for (var key in obj) {
                                var ruleName = key;
                                var modelName = obj[key].modelName;
                                tipStr += "规则 [" + ruleName + "] 不能下线，因为其已被模型 [" + modelName + "] 使用，并且该模型已上线。"
                            }
                        }

                        toastrCog.error(tipStr, 3000);
                    }
                    else if (stopTaskArrNo.length > 0) {//如果被未上线模型使用
                        tipStr = "";
                        for (var i = 0; i < stopTaskArrNo.length; i++) {
                            var obj = stopTaskArrNo[i];
                            for (var key in obj) {
                                var ruleName = key;
                                var modelName = obj[key].modelName;
                                tipStr += "规则 [" + ruleName + "] 被模型 [" + modelName + "] 使用,"
                            }
                        }
                        $("#startModal").modal("show");
                        $("#startModal .modal-title").html("下线");
                        $("#startModal .tipBox").html(tipStr);
                        $("#type").html("您确定要下线所选的" +
                            "<span style='color:rgb(50, 136, 226)'>" + selectArr.length + "</span>" +
                            "个规则" +
                            "<span style='color:rgb(50, 136, 226)'>" + tools.getStr(selectArr, "rulename") + "</span>吗？");
                        $("#startModal").attr("data-id", tools.getStr(selectArr, "idcombinationrule"));
                        $("#startModal").attr("data-code", 0);
                        $("#startModal").modal("show");
                    }
                    else {//如果没有被任务使用，则可以下线
                        var names = tools.getStr(selectArr, "rulename");
                        var ids = tools.getStr(selectArr, "idcombinationrule");
                        $("#startModal").modal("show");
                        $("#startModal .modal-title").html("下线");
                        $("#type").html(
                            "确定要下线所选的" +
                            "<span style='color:rgb(50, 136, 226)'>" + selectArr.length + "</span>" +
                            "个规则" +
                            "<span style='color:rgb(50, 136, 226)'>" + names + "</span>吗？");
                        $("#startModal").attr("data-id", ids);
                        $("#startModal").attr("data-code", 0);
                    }
                }
            });
        },
        copyModel: function () {
            $("#btnCopy").on("click", function () {
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要复制的数据！", 1000);
                } else {
                    var ulBox = $(".nameList");
                    ulBox.html("");
                    $("#copyModal").modal("show");
                    menu.render($("#jsTreeCopy"));
                    $("#copyModal").attr("data-ids", tools.getStr(selectArr, "idcombinationrule"));
//                  渲染模型修改名称列表
                    for (var i = 0; i < selectArr.length; i++) {
                        var id = selectArr[i].idcombinationrule;
                        var name = selectArr[i].rulename;
                        var li = $('<li>' +
                            '<input type="text" class="oldName form-control" value="' + name + '" data-id="' + id + '" disabled title="' + name + '">' +
                            '<span class="fa fa-long-arrow-right"></span>' +
                            '<input type="text" class="newName form-control" value="' + name + '（复制）" id="new' + i + '">' +
                            '</li>');
                        ulBox.append(li);
                        validateFun.initKeyValidatorCopy('#new' + i);
                    }
                    $("#copyModal").on("hidden.bs.modal", function () {
                        $(".jqx-validator-hint").remove();
                        $(".ceng").show();
                        $(".ceng").next().hide();
                        $("#searchMenuCopy").prev().val("");
                    });
                }
            });
            $("#copyBtn").on("click", function () {
                if ($(".jqx-validator-hint").length <= 0) {
                    var params = {};

                    var ref = $('#jsTreeCopy').jstree(true);//获得整个树
                    var sel = ref.get_selected(); //获得所有选中节点，返回值为数组
                    params.idservice = sel[0];
                    params.ruleList = [];
                    var user=parent.$("#spanId").attr("title");
                    var userId=parent.$("#spanId").attr("data-userid");
                    $(".nameList li").each(function () {
                        var obj = {};
                        var id = parseInt($(this).find(".oldName").attr("data-id"));
                        var name = $(this).find(".newName").val();
                        obj.idcombinationrule = id;
                        obj.rulename = name;
                        obj.idAuthor = userId;
                        obj.Author = user;
                        params.ruleList.push(obj);
                    });
                    var ids = $("#copyModal").attr("data-ids");
                    $.ajax({
                        type: "post",
                        url: tools.ruleUrl + "/combinationRule/copyComboRuleToService",
                        dataType: "json",
                        contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                        data: JSON.stringify(params),
//                        data: {
//                            paramJson:JSON.stringify(params)
//                        },
                        success: function (data) {
                            if (data.code == 1) {
                                tools.tableRefresh();
                                toastrCog.success(data.message, 1000)
                            } else {
                                toastrCog.error(data.message, 3000)
                            }
                            $("#copyModal").modal("hide");
                        }
                    })
                }
            });
        },
        moveModel: function () {
            $("#btnMove").on("click", function () {
                var selectArr = $("#myTable").bootstrapTable("getSelections");
                if (selectArr.length <= 0) {
                    toastrCog.error("请选择要移动的数据！", 1000);
                } else {
                    var isMove=true;
                    for(var i=0;i<selectArr.length;i++){
                        if(selectArr[i].status==1){
                            isMove=false;
                            break
                        }
                    }
                    if(isMove){
                        $("#searchMenuMove").prev().val("");
                        menu.render($("#jsTreeMove"));
                        $("#jsTreeMove").animate({scrollTop:0}, "slow");
                        $("#moveRuleModel").modal('show').attr({
                            "data-ids":tools.getStr(selectArr, "idcombinationrule"),
                            "data-names":tools.getStr(selectArr, "rulename")});
                    }else{
                        toastrCog.error("包含已上线的规则，请重新选择！", 2000);
                    }
                }
            });
            $("#moveRuleBtn").on("click", function () {
                var ids = $("#moveRuleModel").attr("data-ids");
                var names = $("#moveRuleModel").attr("data-names");
                var ref = $('#jsTreeMove').jstree(true);//获得整个树
                var sel = ref.get_selected(); //获得所有选中节点，返回值为数组
                if (sel.length == 0) {
                    toastrCog.error("请选择分类节点！", 3000);
                    return
                }
                $.ajax({
                    type: "post",
                    url: tools.ruleUrl + "/combinationRule/updateServiceByIds",
                    dataType: "json",
                    data: {
                        ids: ids,
                        idservice: $("#moveRuleModel").attr("data-idservice")
                    },
                    success: function (data) {
                        if (data.code == 1) {
                            tools.tableRefresh();
                            toastrCog.success(data.message, 1000)
                        } else {
                            toastrCog.error(data.message, 3000)
                        }
                        $("#moveRuleModel").modal("hide");
                    }
                })
            });
        },
        updataSelect: function ($obj, val) {
            $obj.val(val);
            $obj.trigger("chosen:updated");
        },
        getStr: function (selectArr, code) {
            var str = "";
            for (var i = 0; i < selectArr.length; i++) {
                str += selectArr[i][code] + ",";
            }
            str = str.substr(0, str.length - 1);
            return str;
        }
    };
    var modelType = {
        init: function () {
            modelType.add();
            $("#delConBtn").on("click", function () {
                $("#delModalCon").modal("hide");
                menu.delMenu();
            });
        },
        add: function () {
            $("#addType").on("click", function () {
                $("#typeParentModal").parents(".form-group").addClass("hidden");
                $("#addTypeModal").modal("show");
                $("#addTypeModal").attr("data-id", "");
                $("#addTypeModal").attr("data-code", "add");
                $("#addTypeForm").find(".modal-title").html("添加分类");
                $("#addTypeForm")[0].reset();
                $("#proTypeModal").prop("disabled", false);
                tools.updataSelect($("#proTypeModal"), "");
            });
            $("#addTypeBtn").on("click", function () {
                $("#addTypeForm").jqxValidator("validate");
            });
            $("#addTypeForm").on("validationSuccess", function (event) {
                var url = "";
                var code = $("#addTypeModal").attr("data-code");
                var params;
                var idparent = "";
                if (code == "add") {
                    url = tools.ruleUrl + '/service/addservice';
                    idparent = parseInt($("#addTypeModal").attr("data-id"));
                    params = {
                        "idparent": idparent,
                        "service": $("#modelTypeName").val(),
                        "province": $("#proTypeModal").val(),
                        "notes": $("#remarkTypeAdd").val()
                    };
                } else if (code == "edit") {
                    url = tools.ruleUrl + '/service/updateservicebyid';
                    params = {
                        idservice: parseInt($("#addTypeModal").attr("data-id")),
                        service: $("#modelTypeName").val(),
                        notes: $("#remarkTypeAdd").val(),
                        idparent: parseInt($("#addTypeModal").attr("data-parentid")),
                        province: $("#proTypeModal").val()
                    };
                }
                $.ajax({
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: JSON.stringify(params),
                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                    success: function (result) {
                        var msg = result.message;
                        if (result.code == 0) {
                            toastrCog.error(msg, 1000)
                        } else {
                            menu.render($("#jstree"));
                            $("#myTable").bootstrapTable("refresh");
                            toastrCog.success(msg, 1000)
                        }
                        $("#addTypeModal").modal("hide");
                    }
                });
            });
        }
    };
    var draggables = { //模态框拖动
        init: function () {
            this.draggable($('.modal').not("#addRuleModel"));
        },
        draggable: function (obj) {
            $(obj).draggable();
        }
    };
    var rule = {
        subRuleList: [],
        init: function () {
            rule.tab();
            rule.saveSubRule();//确定
            rule.resetSubRule();//重置子规则
            rule.closeRule();//取消操作子规则
            $("#closeAddBtn,#closeEditBtn").on("click", function () {//点击关闭模态框 出现二次确认框
                $("#noSaveModal").modal('show');
            });
            $("#noSaveBtn").on("click", function () {//点击二次确认框 确定按钮
                $("#noSaveModal").modal('hide');
                $("#boxAdd").hide();
                $("#box").show();
                $(".ruleAllBox").hide();
                $("#boxEdit").hide();
            });
            $("#delSubRuleBtn").on("click", function () {//确认删除子规则
                var delModal = $("#delSubRuleModal");
                delModal.modal("hide");
                var type = delModal.attr("data-type");
                var id = delModal.attr("data-id");
                var elem = delModal.attr("data-elem");
                rule.removeSubRule(type, id, $("#" + elem));
            });
            $("body").on("click", "#textContent", function () {//初始化选择文本内容
                var pro = $(this).parents(".ibox").attr("data-pro");
                var proName = bs.getXInY(tools.proArr, "name", "value", pro);
                $("#textModal").modal("show");
                $("#textPro").html(proName).attr("data-code", pro);
                $("#text").html($(this).val()).attr("data-id",$(this).attr("data-id"));
                $("#searchText").prev().val("");
                menuText.render($("#jstreeText"), pro);
                $("#standardTable").bootstrapTable('load', []);
                $("#customTable").bootstrapTable('load', []);
            });
            $("#textBtn").on("click", function () {//选择文本内容确定后操作
                $("#textModal").modal("hide");
                $("#boxEdit #textContent").val($("#text").text()).attr("data-id", $("#text").attr("data-id"));
                $("#boxAdd #textContent").val($("#text").text()).attr("data-id", $("#text").attr("data-id"));
            });
            $("#searchText").on("click", function () {//搜索标准问
                tools.loading($("#standardTable"));
                $.ajax({
                    url: tools.ruleUrl + "/kbdata/searchQuery",
                    type: "post",
                    data: {
                        "city":$("#textPro").attr("data-code"),
                        "query":$("#searchText").prev().val()
                    },
                    success: function (result) {
                        var code = result.code;
                        var data = result.data;
                        if (code) {
                            $("#standardTable").bootstrapTable('load', data.kbdata);
                            $("#customTable").bootstrapTable('load', data.query);
                        } else {
                            toastrCog.error(result.message);
                        }
                    }
                });
            });
        },
        renderRePosObj: function (code, num) {
            tools.rosObjArr = [{"name": "请选择", "value": ""}];
            for (var i = 0; i < rule.subRuleList.length; i++) {
                var obj = {};
                obj.name = "子规则" + rule.subRuleList[i].number;
                obj.value = rule.subRuleList[i].number;
                obj.type = rule.subRuleList[i].type;
                obj.id = rule.subRuleList[i].id;
                if (code) {
                    if (code == "edit" && num == rule.subRuleList[i].number) {
                        obj.disabled = true;
                    }
                }
                tools.rosObjArr.push(obj);
            }
            bs.selectDownNoDisabled($(".relativeObj"), tools.rosObjArr, "", "100px");
        },
        tab: function () {
            $(".tabTitle span").on("click", function () {
                if (!$(this).hasClass("disabled")) {
                    var index = $(this).index();
                    $(this).addClass("on").siblings("span").removeClass("on");
                    $(".tab").removeClass("on");
                    $(".tab" + index).addClass("on");
                    // var box = $(this).parents(".ibox").find(".ibox-content").eq(index);
                    // box.find("select.absolutePos").next().nextAll().hide();
                    // box.find("select.relativeObj").next().next().nextAll().hide();
                    $(".jqx-validator-hint").remove();
                }
            })
        },
        saveSubRule: function () {
            $(".saveRule").unbind("click").on("click", function () {
                var box = $(this).parents(".ibox-content");
                box.find(".absoluteTxt").focus().blur();
                box.find(".countP").focus().blur();
                var minElem=box.find(".minT");
                var maxElem=box.find(".maxT");
                minElem.focus().blur();
                maxElem.focus().blur();
                if ($(".jqx-validator-error-label").length <= 0 && $(".jqx-validator-hint").length <= 0) {
                    var obj = {};
                    var type = $(this).parents("form").find(".tabTitle span.on").attr("data-type");
//                    组合规则id
                    obj.idcombinationrule = $(this).parents(".ibox").attr("data-id");
//                    文本
                    var txtContent = box.find("#textContent");
                    rule.commonFilter(obj, "content", "文本", txtContent);
                    if (txtContent != "") {
                        obj.kbdataid = box.find("#textContent").attr("data-id");
                    }
//                    位置
                    var aPosSelect = box.find(".absolute .absolutePos");
                    var aPosInput = box.find(".absolute .absoluteTxt");
                    var relativeRule = box.find(".relative .relativeRule");
                    var rObjSelect = box.find(".relative .relativeObj");
                    var rPosSelect = box.find(".relative .relativePos");
                    var rPosInput = box.find(".relative .absoluteTxt");
                    if (aPosInput.length > 0 && aPosInput.val() != "") {
                        if (aPosSelect.val() == "大于等于") {
                            obj.absoluteposition_after = aPosInput.val();
                        } else if (aPosSelect.val() == "小于等于") {
                            obj.absoluteposition_before = aPosInput.val();
                        } else if (aPosSelect.val() == "录音结尾") {
                            obj.absoluteposition_end = aPosInput.val();
                        }
                    }
                    var rPosInputVal=rPosInput.val();
                    if (rPosInput.length > 0 && rPosInput.css("display")!="none") {
                        if(rPosInputVal == ""){
                            rPosInputVal=-1;
                        }
                        if (rPosSelect.val() == "0") {//某个子规则前几秒
                            obj.relativeposition_before = rPosInputVal;
                        } else if (rPosSelect.val() == "1") {//某个子规则后几秒
                            obj.relativeposition_after = rPosInputVal;
                        } else if (rPosSelect.val() == "2") {//某个子规则前后几秒
                            obj.relativeposition_before = rPosInputVal;
                            obj.relativeposition_after = rPosInputVal;
                        }
                        var relativeposition_obj = bs.changeState(bs.getXInY(tools.rosObjArr, "type", "value", rObjSelect.val()), tools.typeArr) + "," + bs.getXInY(tools.rosObjArr, "id", "value", rObjSelect.val());
                        obj.relativeposition_obj = relativeposition_obj;
                    }
//                    次数
                    var countP = box.find(".countP");
                    rule.commonFilter(obj, "times_equal", "次数", countP);
//                    声道
                    var speechP = box.find(".speechP");
                    if(type=="抢插话"){
                        rule.commonFilter(obj, "channel_before", "声道", speechP);
                    }else{
                        rule.commonFilter(obj, "channel", "声道", speechP);
                    }

//                    命中
                    var hitP = box.find(".hitP");
                    rule.commonFilter(obj, "hit", "命中", hitP);
//                    时长/音量差值/语速
                    var timeMin = box.find(".minT");
                    var timeMax = box.find(".maxT");
                    if (type == "静音" || type == "声道") {
                        rule.commonFilter(obj, "duration_more", "时长", timeMin.eq(0));
                        rule.commonFilter(obj, "duration_less", "时长", timeMax.eq(0));
                    } else if (type == "音量") {
                        rule.commonFilter(obj, "difmore", "音量差值", timeMin.eq(0));
                        rule.commonFilter(obj, "difless", "音量差值", timeMax.eq(0));
                    } else if (type == "语速") {
                        rule.commonFilter(obj, "more", "语速", timeMin.eq(0));
                        rule.commonFilter(obj, "less", "语速", timeMax.eq(0));
                        rule.commonFilter(obj, "duration_more", "时长", timeMin.eq(1));
                        rule.commonFilter(obj, "duration_less", "时长", timeMax.eq(1));
                    }
                    if ($(this).attr("data-id")) {
                        var code = $(this).attr("data-code");
                        obj[code] = $(this).attr("data-id");
                    }
//                    添加子规则
                    var code = $(this).parents(".ibox").find(".addRuleTitle").attr("data-code");//添加子规则还是编辑子规则的标识
                    var res=rule.addSubRule(type, obj, code);
                    if(res){
                        var ibox = $(this).parents(".ibox");
                        var subTable = ibox.find(".subTable");
                        rule.subRuleList.sort(bs.sortBy("number"));

                        var oTableSub = new TableInit1();
                        oTableSub.Init(subTable, rule.subRuleList);
//                    添加后清除记录
                        $(this).next().click();
                        var scrollHeight = $(this).parents('.ibox').prop("scrollHeight");
                        $(this).parents('.ibox').scrollTop(scrollHeight, 200);
                    }
                }

            })
        },
        commonFilter: function (obj, code, name, elem) {
            if (elem.length > 0 && elem.val() != "") {
                obj[code] = elem.val();
            }
        },
        resetSubRule: function () {
            $(".resetRule").on("click", function () {//重置子规则内容
                var box = $(this).parents(".ibox-content");
                var index = box.index();
                box.find("select").val("").trigger("chosen:updated");
                box.find("input").val("").focus().blur();
                box.find("select.absolutePos").next().nextAll().hide();
                box.find("select.relativeObj").next().next().nextAll().hide();
                box.find("#textContent").attr("data-id", "");
//                恢复为添加子规则状态
                $(this).parents(".ibox").find(".addRuleTitle").html("添加子规则").attr("data-code", "add");
                $(this).prev().attr({"data-id": "", "data-code": ""});
//                所有类型都可以点击解开
                var spanTitle = $(this).parents(".ibox").find(".tabTitle span");
                spanTitle.removeClass("disabled");
                spanTitle.removeClass("on");
                spanTitle.eq(0).click();
                rule.renderRePosObj();
                $("label.jqx-validator-error-label").remove();
            })
        },
        closeRule: function () {
            $(".closeRule").on("click", function () {//重置子规则内容
                var subEditForm = $(this).parents("form");
                var tableForm = subEditForm.prev("form");
                subEditForm.hide();
                tableForm.show();
                if (tableForm.find(".subTable").html() == "") {
                    tableForm.find(".subTable").hide();
                }
                tableForm.find(".goAdd").show();
                $(this).prev(".resetRule").click();
            })
        },
        columnsSubRule: function (code) {//子规则列显示
            var arr = [
                {
                    title: '序号',//标题  可不加
                    field: 'number',
                    width: 60
                },
                {
                    field: 'type',
                    title: '类型',
                    width: 100
                },
                {
                    field: 'content',
//                    width: 300,
                    title: '内容',
                    formatter: function (value, row, index) {
                        var timesStr = "";
                        var voiceSpeedStr = "";
                        var channel = "";
                        var contentStr = "";
                        var durationStr = "";
                        var hitStr = "";
                        if (row.voiceSpeedStr) {
                            voiceSpeedStr = row.voiceSpeedStr;
                        }
                        if (row.timesStr) {
                            timesStr = row.timesStr;
                        }
                        if (row.channel) {
                            channel = row.channel;
                        }
                        if (row.contentStr) {
                            contentStr = row.contentStr;
                        }
                        if (row.durationStr) {
                            durationStr = row.durationStr;
                        }
                        if (row.hit!=null) {
                            var hit = row.hit;
                            if (hit == "0") {
                                hitStr = "否"
                            } else if (hit == "1") {
                                hitStr = "是"
                            }
                        }

                        var conHtml = "";
                        if (voiceSpeedStr) {
                            conHtml += voiceSpeedStr + "</br>";
                        }
                        if (timesStr) {
                            conHtml += timesStr + "</br>";
                        }
                        if (channel) {
                            conHtml += channel + "</br>";
                        }
                        if (contentStr) {
                            conHtml += contentStr + "</br>";
                        }
                        if (durationStr) {
                            conHtml += durationStr + "</br>";
                        }
                        if (hitStr) {
                            conHtml += "命中：" + hitStr + "</br>";
                        }
                        return conHtml;
                    }
                },
                {
                    field: 'position',
                    title: '位置'
                }
            ];
            if (code == "has") {
                arr.push({
                    width: 100,
                    field: 'Button',
                    title: '操作',
                    formatter: function (value, row, index) {
                        return [
                            '<button class="btn btn-info editSubRule" type="button" style="margin-bottom: 6px;">编辑</button><button class="btn btn-warning delSubRule" type="button" data-id="' + row.number + '">删除</button>'
                        ]
                    },
                    events: {
                        'click .editSubRule': function (e, value, row, index) {
                            e.preventDefault();
                            var box = $(this).parents(".ibox").find(".ibox-content.on");
                            box.find(".resetRule").click();
                            var row1 = rule.renderSubRule(row.type, row.id);
//                            子规则序号
                            var number = row1.number;
                            $(this).parents(".ibox").find(".addRuleTitle").html("编辑子规则" + number).attr("data-code", "edit");
                            rule.renderRePosObj("edit", number);
//                            类型
                            var type = row1.type;
                            var spanTitleElem = $(this).parents(".ibox").find(".tabTitle span[data-type='" + type + "']");
                            $(this).parents(".ibox").find(".tabTitle span").removeClass("disabled");
                            spanTitleElem.click();
                            spanTitleElem.siblings().addClass("disabled");
                            box = $(this).parents(".ibox").find(".ibox-content.on");
                            var spanTitle = $(this).parents(".ibox").find(".tabTitle span.on");
                            box.find(".saveRule").attr({"data-id": row.id, "data-code": spanTitle.attr("data-code")});
//                            绝对位置
                            var absoluteposition = row1.absoluteposition;
                            var ab_character = row1.ab_character;
                            var absoluteposition_after = row1.absoluteposition_after;
                            var absoluteposition_before = row1.absoluteposition_before;
                            var absoluteposition_end = row1.absoluteposition_end;
                            if (absoluteposition && absoluteposition != "") {
                                box.find(".absolutePos").val(ab_character).trigger("chosen:updated");
                                if (ab_character == "大于等于") {
                                    box.find(".absolute .absoluteTxt").val(absoluteposition_after);
                                } else if (ab_character == "小于等于") {
                                    box.find(".absolute .absoluteTxt").val(absoluteposition_before);
                                } else if (ab_character == "录音结尾") {
                                    box.find(".absolute .absoluteTxt").val(absoluteposition_end);
                                }
                                box.find(".absolutePos").next().nextAll().show();
                            }
//                            相对位置
                            var relativeNumber = row1.relativeposition_obj_number;
                            var re_character = row1.re_character;
                            var relativeposition = row1.relativeposition;
                            var relativeposition_after = row1.relativeposition_after;
                            relativeposition_after=relativeposition_after==-1?"":relativeposition_after;
                            var relativeposition_before = row1.relativeposition_before;
                            relativeposition_before=relativeposition_before==-1?"":relativeposition_before;
                            if (relativeposition && relativeposition != "") {
                                box.find(".relativeObj").val(relativeNumber).trigger("chosen:updated");
                                box.find("select.absolutePos").next().nextAll().show();
                                box.find("select.relativeObj").next().next().nextAll().show();
                                if (re_character == "前") {
                                    box.find(".relativePos").val("0").trigger("chosen:updated");
                                    box.find(".relative .absoluteTxt").val(relativeposition_before);
                                } else if (re_character == "后") {
                                    box.find(".relativePos").val("1").trigger("chosen:updated");
                                    box.find(".relative .absoluteTxt").val(relativeposition_after);
                                } else if (re_character == "前后") {
                                    box.find(".relativePos").val("2").trigger("chosen:updated");
                                    box.find(".relative .absoluteTxt").val(relativeposition_after);
                                }

                            }
//                            文本内容
                            var contentStr = row1.contentStr;
                            if (type == "文本") {
                                box.find("#textContent").attr("data-id", row1.kbdataidStr);
                            }
//                            命中
                            var hit = row1.hit;
//                            次数
                            var times_equal = row1.times_equal;
//                            声道
                            var channel = row1.channel;
//                            时长
                            var conditionStart = "";
                            var conditionEnd = "";
                            var speedTimeStart="";//语速里的时长
                            var speedTimeEnd="";//语速里的时长
                            if (type == "静音" || type == "声道") {
                                conditionStart = row1.duration_more;
                                conditionEnd = row1.duration_less;
                            } else if (type == "音量") {
                                conditionStart = row1.difmore;
                                conditionEnd = row1.difless;
                            } else if (type == "语速") {
                                conditionStart = row1.more;
                                conditionEnd = row1.less;
                                speedTimeStart = row1.duration_more;
                                speedTimeEnd = row1.duration_less;
                            }

                            box.find(".minT").eq(0).val(conditionStart);
                            box.find(".maxT").eq(0).val(conditionEnd);
                            if(speedTimeStart){
                                box.find(".minT").eq(1).val(speedTimeStart);
                            }
                            if(speedTimeEnd){
                                box.find(".maxT").eq(1).val(speedTimeEnd);
                            }
                            box.find("#textContent").val(contentStr);
                            if (channel != null) {
                                var channelVal = "";
                                if (channel == "坐席") {
                                    channelVal = 0
                                } else if (channel == "客户") {
                                    channelVal = 1
                                } else {
                                    channelVal = 2
                                }
                                box.find(".speechP").val(channelVal).trigger("chosen:updated");
                            }
                            if (hit != null) {
                                box.find(".hitP").val(hit).trigger("chosen:updated");
                            }
                            box.find(".countP").val(times_equal);

                        },
                        'click .delSubRule': function (e, value, row, index) {
                            e.preventDefault();
                            var number = row.number;
                            $("#delSubRuleModal").modal("show").attr({
                                "data-id": row.id,
                                "data-type": row.type,
                                "data-elem": $(this).parents(".ibox").attr("id")
                            });
                            $("#delSubRuleName").html("您确定要删除<span style='color:rgb(50, 136, 226)'>子规则" + number + "</span>吗？")
                        }
                    }
                });
            }
            return arr;

        },
        getRuleOne: function (type, id) {
            var url = "";
            var params = {};
            if (type == "文本") {
                url = "/text/showchildlisttextbyid";
                params.idtext = id;
            } else if (type == "静音") {
                url = "/mute/showchildlistmutebyid";
                params.idmute = id;
            } else if (type == "音量") {
                url = "/volume/showchildlistvolumebyid";
                params.idvolume = id;
            } else if (type == "语速") {
                url = "/voiceSpeed/showchildlistvoicespeedbyid";
                params.idvoiceSpeed = id;
            } else if (type == "负面情绪") {
                url = "/negative/showchildlistnegativebyid";
                params.idnegative = id;
            } else if (type == "抢插话") {
                url = "/grab/showchildlistgrabbyid";
                params.idgrab = id;
            } else {
                url = "/channels/showchildlistchannelsbyid";
                params.idchannels = id;
            }
            var obj;
            $.ajax({
                url: tools.ruleUrl + url,
                type: "post",
                data: params,
                async: false,
                success: function (result) {
                    var code = result.code;
                    var data = result.data;
                    if (code) {
                        obj = data;
                        obj.id = id;
                    } else {
                        toastrCog.error(result.message);
                    }
                }
            });
            return obj;
        },
        addSubRule: function (type, obj, codeT) {
            var url = "";
            var typeId = "";
            var res=true;
            if (type == "文本") {
                url = "/text/addtext";
                typeId = "idtext";
                if(!obj.content){
                    toastrCog.error("请选择文本内容！");
                    res=false;
                }
            } else if (type == "静音") {
                url = "/mute/addmute";
                obj.hit = 1;
                typeId = "idmute";
                if(!obj.duration_more && !obj.duration_less){
                    toastrCog.error("请填写时长！");
                    res=false;
                }
            } else if (type == "音量") {
                url = "/volume/addvolume";
                obj.hit = 1;
                typeId = "idvolume";
                if(!obj.difmore && !obj.difless){
                    toastrCog.error("请填写音量差值！");
                    res=false;
                }
            } else if (type == "语速") {
                url = "/voiceSpeed/addvoiceSpeed";
                obj.hit = 1;
                typeId = "idvoicespeed";
                if(!obj.more && !obj.less){
                    toastrCog.error("请填写语速！");
                    res=false;
                }
            } else if (type == "负面情绪") {
                url = "/negative/addnegative";
                obj.hit = 1;
                typeId = "idnegative";
            } else if (type == "抢插话") {
                url = "/grab/addgrab";
                obj.hit = 1;
                typeId = "idgrab";
            } else {
                url = "/channels/addchannels";
                typeId = "idchannels";
                if(!obj.duration_more&& !obj.duration_less){
                    toastrCog.error("请填写时长！");
                    res=false;
                }
            }
            if(res){
                $.ajax({
                    url: tools.ruleUrl + url,
                    type: "post",
                    data: JSON.stringify(obj),
                    async: false,
                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                    success: function (result) {
                        var code = result.code;
                        var data = result.data;
                        if (code) {
                            toastrCog.success(result.message, 1000);
                            var ruleObj = rule.getRuleOne(type, data);
                            if (codeT == "add") {
                                if (ruleObj) {
                                    rule.subRuleList.push(ruleObj);
                                }
                            } else {
                                for (var i = 0; i < rule.subRuleList.length; i++) {
                                    if (rule.subRuleList[i].id == obj[typeId]) {
                                        if (ruleObj) {
                                            rule.subRuleList.splice(i, 1, ruleObj);
                                        }

                                    }
                                }
                            }
                            rule.renderRePosObj();
                        } else {
                            toastrCog.error(result.message, 1000);
                        }
                    }
                });
            }
            return res;

        },
        renderSubRule: function (type, id) {
            var url = "";
            var params = {};
            if (type == "文本") {
                url = "/text/showdetailtextbyid";
                params.idtext = id;
            } else if (type == "静音") {
                url = "/mute/showdetailmutebyid";
                params.idmute = id;
            } else if (type == "音量") {
                url = "/volume/showdetailvolumebyid";
                params.idvolume = id;
            } else if (type == "语速") {
                url = "/voiceSpeed/showdetailvoicespeedbyid";
                params.idvoiceSpeed = id;
            } else if (type == "负面情绪") {
                url = "/negative/showdetailnegativebyid";
                params.idnegative = id;
            } else if (type == "抢插话") {
                url = "/grab/showdetailgrabbyid";
                params.idgrab = id;
            } else {
                url = "/channels/showdetailchannelsbyid";
                params.idchannels = id;
            }
            var result1;
            $.ajax({
                url: tools.ruleUrl + url,
                type: "post",
                data: params,
                async: false,
//                contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                success: function (result) {
                    var code = result.code;
                    if (code == 1) {
                        result1 = result.data;
                    } else {
                        toastrCog.error(result.message);
                    }
                }
            });
            return result1;
        },
        removeSubRule: function (type, id, $elem) {
            var url = "";
            var params = {};
            if (type == "文本") {
                url = "/text/deletetextbyid";
                params.idtext = id;
            } else if (type == "静音") {
                url = "/mute/deletemutebyid";
                params.idmute = id;
            } else if (type == "音量") {
                url = "/volume/deletevolumebyid";
                params.idvolume = id;
            } else if (type == "语速") {
                url = "/voiceSpeed/deletevoiceSpeedbyid";
                params.idvoiceSpeed = id;
            } else if (type == "负面情绪") {
                url = "/negative/deletenegativebyid";
                params.idnegative = id;
            } else if (type == "抢插话") {
                url = "/grab/deletegrabbyid";
                params.idgrab = id;
            } else {
                url = "/channels/deletechannelsbyid";
                params.idchannels = id;
            }
            $.ajax({
                url: tools.ruleUrl + url,
                type: "post",
                data: params,
                async: false,
                success: function (result) {
                    var code = result.code;
                    if (code == 1) {
                        for (var i in rule.subRuleList) {
                            if (rule.subRuleList[i].id == id) {
                                rule.subRuleList.splice(i, 1);
                                break;
                            }
                        }
                        tools.rootRuleData(rule.subRuleList, $elem.find("table"));
                        rule.renderRePosObj();
                    } else {
                        toastrCog.error(result.message, 3000);
                    }
                }
            });
        },
    };
    var validateFun = {
        init: function () {
            this.initKeyValidatorAdd();
            this.initKeyValidatorEdit();
            this.initKeyValidatorAddType();
            $(".absoluteTxt").each(function () {//绝对位置相对位置验证
                var indexElem = $(this).attr("class").split(" ")[2];
                var form = $(this).parents("form");
                validateFun.initSubRuleNumRange(form, "." + indexElem);
            });
            $(".countP").each(function () {//次数验证
                var indexElem = $(this).attr("class").split(" ")[2];
                var form = $(this).parents("form");
                validateFun.initSubRuleCount(form, "." + indexElem);
            });
            $(".minT,.maxT").each(function () {//时长比较大小验证
                var indexElem = $(this).attr("class").split(" ")[2];
                var form = $(this).parents("form");
                validateFun.initSubRuleCompare(form, "." + indexElem);
            });

        },
        initKeyValidatorAdd: function () {
            $("#addModelForm").jqxValidator({
                rules: [
                    {
                        input: '#ruleNameAdd',
                        message: '规则名称不能为空',
                        action: 'keyup,blur',
                        rule: 'required'
                    }
                    , {
                        input: '#ruleNameAdd',
                        message: '规则名称不能包含空格!',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val().indexOf(" ") > -1) {
                                result = false
                            }
                            return result;
                        }
                    },
                    {
                        input: '#ruleNameAdd',
                        message: '规则名称不能多余' + tools.maxTextLength + '字！',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val() != "") {
                                if ($(input).val().length > 50) {
                                    return false
                                }
                            }
                            return result;
                        }
                    }
                    , {
                        input: '#ruleNameAdd',
                        message: "规则名称已经存在!",
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var validate = true;
                            var url = tools.ruleUrl + "/combinationRule/isExistRuleName";
                            var data = {
                                rulename: $(input).val(),
                                idservice: $("#ruleClassifyAdd").attr("data-id")
                            };
                            if ($("#ruleNameAdd").attr("data-val") != $(input).val()) {
                                $.ajax({
                                    url: url,
                                    timeout: 10000,
                                    async: false,
                                    type: 'POST',
                                    data: JSON.stringify(data),
                                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                                    success: function (msg) {
                                        if (msg.data) {
                                            validate = false;
                                        }
                                    }
                                });
                            }

                            return validate;
                        }
                    }
                    , {
                        input: '#scoreAdd',
                        message: '请输入大于等于0、小于等于10000的整数',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            var reg = /^\d+$/;
                            var val = $(input).val();
                            if (val != "") {
                                if (!reg.test(val)) {
                                    result = false
                                } else {
                                    if (val < 0 || val > 10000) {
                                        result = false
                                    }
                                }
                            }
                            return result;
                        },
                    }, {
                        input: '#remarkAdd',
                        message: '最多输入255个字符!',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val() != "") {
                                if ($(input).val().length > 255) {
                                    result = false
                                }
                            }
                            if (result) {
                                $(input).removeClass("jqx-validator-error-element");
                            }
                            return result;
                        }
                    }

                ],
                hintType: "label"
            });
        },
        initKeyValidatorEdit: function () {
            $("#editForm").jqxValidator({
                rules: [
                    {
                        input: '#ruleNameEdit',
                        message: '规则名称不能为空',
                        action: 'keyup,blur',
                        rule: 'required'
                    }
                    , {
                        input: '#ruleNameEdit',
                        message: '规则名称不能包含空格!',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val().indexOf(" ") > -1) {
                                result = false
                            }
                            return result;
                        }
                    }, {
                        input: '#ruleNameEdit',
                        message: '规则名称不能多余' + tools.maxTextLength + '字！',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val() != "") {
                                if ($(input).val().length > 50) {
                                    return false
                                }
                            }
                            return result;
                        }
                    }
                    , {
                        input: '#ruleNameEdit',
                        message: "规则名称已经存在!",
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var validate = true;
                            var url = tools.ruleUrl + "/combinationRule/isExistRuleName";
                            var data = {
                                rulename: $(input).val(),
                                idservice: $("#ruleClassifyEdit").attr("data-id")
                            };
                            if ($("#ruleNameEdit").attr("data-val") != $(input).val()) {
                                $.ajax({
                                    url: url,
                                    timeout: 10000,
                                    async: false,
                                    type: 'POST',
                                    data: JSON.stringify(data),
                                    contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                                    success: function (msg) {
                                        if (msg.data) {
                                            validate = false;
                                        }
                                    }
                                });
                            }
                            return validate;
                        }
                    }
                    , {
                        input: '#scoreEdit',
                        message: '请输入大于等于0、小于等于10000的整数',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            var reg = /^\d+$/;
                            var val = $(input).val();
                            if (val != "") {
                                if (!reg.test(val)) {
                                    result = false
                                } else {
                                    if (val < 0 || val > 10000) {
                                        result = false
                                    }
                                }
                            }
                            return result;
                        },
                    }
                ],
                hintType: "label"
            });
        },
        initKeyValidatorAddType: function () {
            $("#addTypeForm").jqxValidator({
                rules: [
                    {
                        input: '#proTypeModalAddInput',
                        message: '请选择省份!',
                        action: 'change,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val() == "") {
                                result = false
                            }
                            return result;
                        }
                    }
                    ,
                    {
                        input: '#modelTypeName',
                        message: '分类名称不能为空',
                        action: 'keyup,blur',
                        rule: 'required'
                    }, {
                        input: '#modelTypeName',
                        message: '分类名称不能包含空格!',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val().indexOf(" ") > -1) {
                                result = false
                            }
                            return result;
                        }
                    },
                    {
                        input: '#modelTypeName',
                        message: '分类名称不能多余' + tools.maxTextLength + '字！',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            if ($(input).val() != "") {
                                if ($(input).val().length > 50) {
                                    return false
                                }
                            }
                            return result;
                        }
                    }
//                    , {
//                        input: '#modelTypeName',
//                        message: "分类名称已经存在!",
//                        action: 'keyup,blur',
//                        rule: function (input, commit) {
//                            var validate = true;
//                            var isAjax = true;
//                            var url = basePath + "rest/model/checkOnly/modelTypeByExample";
//                            var code = $("#addTypeModal").attr("data-code");
//                            var id = $("#addTypeModal").attr("data-id");
//                            var data;
//                            if (code == "add") {
//                                var ref = $('#jstree').jstree(true);//获得整个树
//                                var sel = ref.get_selected(false);
//                                data = {
//                                    name: $(input).val(),
//                                    parentid: sel[0],
//                                    provincecode: $("#proTypeModal").val()
//                                };
//                            } else {
//                                var node = $("#jstree").jstree("get_node", id);
//                                if (node.text == $(input).val()) {
//                                    isAjax = false;
//                                }
//                                data = {
//                                    id: id,
//                                    name: $(input).val(),
//                                    parentid: node.parent,
//                                    provincecode: $("#proTypeModal").val()
//                                };
//                            }
//                            if (isAjax) {
//                                $.ajax({
//                                    url: url, data: data, timeout: 10000,
//                                    async: false, type: 'POST',
//                                    success: function (msg) {
//                                        if (msg.code < 0) {
//                                            input.focus();
//                                            validate = false;
//                                        }
//                                    }
//                                });
//                            }
//                            return validate;
//                        }
//                    }
                ],
                hintType: "label"
            });
        },
        initKeyValidatorCopy: function (elem) {
            $("#copyForm").jqxValidator({
                position: 'right',
                rules: [
                    {
                        input: elem,
                        message: "规则名称已经存在!",
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var validate = true;
                            var url = tools.ruleUrl + "/combinationRule/isExistRuleName";
                            var ref = $('#jsTreeCopy').jstree(true);//获得整个树
                            var sel = ref.get_selected(); //获得所有选中节点，返回值为数组
                            var data = {
                                rulename: $(input).val(),
                                idservice: sel[0]
                            };
                            $.ajax({
                                url: url,
                                timeout: 10000,
                                async: false,
                                type: 'POST',
                                data: JSON.stringify(data),
                                contentType: "application/json",  //缺失会出现URL编码，无法转成json对象
                                success: function (msg) {
                                    if (msg.data) {
                                        validate = false;
                                    }
                                }
                            });
                            return validate;
                        }
                    }
                ]
            });
            $('#copyForm').jqxValidator('updatePosition');
        },
        initSubRuleCount: function (form, elem) {
            form.jqxValidator({
                position: 'right',
                rules: [
                    {//次数 验证
                        input: elem,
                        message: '请输入10000以内的正整数',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            var reg = /^[1-9][0-9]{0,3}$|^10000$/;
                            var val = $(input).val();
                            if (val != "") {
                                if (!reg.test(val)) {
                                    result = false
                                }
                            }
                            return result;
                        },
                        hintRender: function (message, input) {
                            var box = $(input).parent();
                            if (box.find("label").length > 0) {
                                box.find("label.jqx-validator-error-label").remove();
                            }
                            var label = $("<label class='jqx-validator-error-label' " +
                                "style='border: 1px solid #6E0000;" +
                                "background-color: #942724;color: #fff;left: 182px;top: 6px !important;z-index:10;'" +
                                ">" + message + "</label>");
                            label.insertAfter($(input));
                            return label;
                        }
                    }
                ]
            });
            form.jqxValidator('updatePosition');
        },
        initSubRuleCompare: function (form, elem, tip) {
            var typeIndex = $(elem).parents(".ibox-content").index();
            var type = $(elem).attr("data-type");
            var objT= {//时长都不能输入0 但是可以输入-1
                input: elem,
                message: '请输入大于0、小于等于10000的数字',
                action: 'keyup,blur',
                rule: function (input, commit) {
                    var result = true;
                    var reg = /^(?!0+$)(\d+(\.\d+)?)$|^-1$/;
                    var val = $(input).val();
                    if (val != "") {
                        if (!reg.test(val)) {
                            result = false
                        } else {
                            if (val < -1 || val > 10000) {
                                result = false
                            }
                        }
                    }
                    if(!result){
                        $(input).focus()
                    }
                    return result;
                },
                hintRender: function (message, input) {
                    var label = $("<label class='jqx-validator-error-label' " +
                        "style='border: 1px solid #6E0000;background-color: #942724;color: #fff;top:7px !important;z-index: 9999;'" +
                        ">" + message + "</label>");

                    label.insertAfter($(input));
                    label.css("left",$(input).offset().left+"px");
                    return label;
                }
            };
            var objYin= {//音量可以输入0
                input: elem,
                message: '请输入大于等于0、小于等于10000的数字',
                action: 'keyup,blur',
                rule: function (input, commit) {
                    var result = true;
                    var reg = /^(\d+(\.\d+)?)$/;
                    var val = $(input).val();
                    if (val != "") {
                        if (!reg.test(val)) {
                            result = false
                        } else {
                            if (val < 0 || val > 10000) {
                                result = false
                            }
                        }
                    }
                    if(!result){
                        $(input).focus()
                    }
                    return result;
                },
                hintRender: function (message, input) {
                    var label = $("<label class='jqx-validator-error-label' " +
                        "style='border: 1px solid #6E0000;background-color: #942724;color: #fff;top:7px !important;z-index: 9999;'" +
                        ">" + message + "</label>");

                    label.insertAfter($(input));
                    label.css("left",$(input).offset().left+"px");
                    return label;
                }
            };
            var objYu= {//语速不可以输入0
                input: elem,
                message: '请输入大于0、小于等于10000的数字',
                action: 'keyup,blur',
                rule: function (input, commit) {
                    var result = true;
                    var reg = /^(?!0+$)(\d+(\.\d+)?)$/;
                    var val = $(input).val();
                    if (val != "") {
                        if (!reg.test(val)) {
                            result = false
                        } else {
                            if (val < 0 || val > 10000) {
                                result = false
                            }
                        }
                    }
                    if(!result){
                        $(input).focus()
                    }
                    return result;
                },
                hintRender: function (message, input) {
                    var label = $("<label class='jqx-validator-error-label' " +
                        "style='border: 1px solid #6E0000;background-color: #942724;color: #fff;top:7px !important;z-index: 9999;'" +
                        ">" + message + "</label>");

                    label.insertAfter($(input));
                    label.css("left",$(input).offset().left+"px");
                    return label;
                }
            };
            var objRequired={//下限为必填项
                input: elem,
                message: '',
                action: 'keyup,blur',
                rule: function (input, commit) {
                    var result = true;
                    var val = $(input).val();
                    if (val == "") {
                        if ($(input).hasClass("minT")) {
                            result = false
                        }
                    }
                    if(!result){
                        $(input).focus()
                    }
                    return result;
                },
                hintRender: function (message, input) {
                    if ($(input).next("label").length > 0) {
                        $(input).next("label.jqx-validator-error-label").remove();
                    }
                    var index = $(input).parents(".ibox-content").index();
                    var typeT=$(input).attr("data-type");
                    var message = "";
                    if (index == 2 || index == 7) {
                        message = "时长下限不能为空"
                    } else if (index == 3) {
                        message = "音量差值下限不能为空"
                    } else if (index == 4) {
                        if(typeT == "timeDur"){
                            message = "时长下限不能为空"
                        }else{
                            message = "语速下限不能为空"
                        }
                    }
                    var label = $("<label class='jqx-validator-error-label' " +
                        "style='border: 1px solid #6E0000;background-color: #942724;color: #fff;top:7px !important;z-index: 9999;'" +
                        ">" + message + "</label>");

                    label.insertAfter($(input));
                    label.css("left",$(input).offset().left+"px");
                    return label;
                }
            };
            var objCompare={
                input: elem,
                message: "",
                action: 'keyup,blur',
                rule: function (input, commit) {
                    var result = true;
                    var val = $(input).val();
                    if ($(input).hasClass("minT")) {
                        var maxVal = $(input).parents(".col-sm-9").find(".maxT").val();
                        if (val != "" && maxVal != "") {
                            if (parseFloat(val) > parseFloat(maxVal)) {
                                result = false;
                            }
                        }
                    } else {
                        var minVal = $(input).parents(".col-sm-9").find(".minT").val();
                        if (val != "" && minVal != "") {
                            if (parseFloat(val) < parseFloat(minVal)) {
                                result = false;
                            }
                        }
                    }
                    if(!result){
                        $(input).focus()
                    }
                    return result;
                },
                hintRender: function (message, input) {
                    if ($(input).next("label").length > 0) {
                        $(input).next("label.jqx-validator-error-label").remove();
                    }
                    var index = $(input).parents(".ibox-content").index();
                    var typeT=$(input).attr("data-type");
                    var message = "";
                    if (index == 2 || index == 7) {
                        message = "时长上限不得小于时长下限"
                    } else if (index == 3) {
                        message = "音量差值上限不得小于音量差值下限"
                    } else if (index == 4) {
                        if(typeT == "timeDur"){
                            message = "时长上限不得小于时长下限"
                        }else{
                            message = "语速上限不得小于语速下限"
                        }

                    }
                    var label = $("<label class='jqx-validator-error-label' " +
                        "style='border: 1px solid #6E0000;background-color: #942724;color: #fff;top:7px !important;z-index: 9999;'" +
                        ">" + message + "</label>");

                    label.insertAfter($(input));
                    label.css("left",$(input).offset().left+"px");
                    return label;
                }
            };
            var rules=[];
            if(typeIndex){
                if (typeIndex == 2 || typeIndex == 7) {//时长
                    rules.push(objRequired);
                    rules.push(objT);
                    rules.push(objCompare);
                } else if (typeIndex == 3) {//音量
                    rules.push(objRequired);
                    rules.push(objYin);
                    rules.push(objCompare);
                } else if (typeIndex == 4) {//语速
                    if(type=="timeDur"){
                        rules.push(objT);
                    }else{
                        rules.push(objRequired);
                        rules.push(objYu);
                    }
                    rules.push(objCompare);
                }
            }
            validateFun.destroy(form, elem);
            form.jqxValidator({
                position: 'right',
                rules: rules
            });
            form.jqxValidator('updatePosition');
        },
        initSubRuleNumRange: function (form, elem) {
            form.jqxValidator({
                position: 'right',
                rules: [
                    {//时长 位置的验证
                        input: elem,
                        message: '请输入大于等于0、小于等于10000的数字',
                        action: 'keyup,blur',
                        rule: function (input, commit) {
                            var result = true;
                            var reg = /^\d+(\.\d+)?$/;
                            var val = $(input).val();
                            if (val != "") {
                                if (!reg.test(val)) {
                                    result = false
                                } else {
                                    if (val < 0 || val > 10000) {
                                        result = false
                                    }
                                }
                            }
                            return result;
                        },
                        hintRender: function (message, input) {
                            var box = $(input).parent();
                            if (box.find("label").length > 0) {
                                box.find("label.jqx-validator-error-label").remove();
                            }
                            var label = $("<label class='jqx-validator-error-label' " +
                                "style='width:260px;border: 1px solid #6E0000;background-color: #942724;color: #fff;top: 7px !important'" +
                                ">" + message + "</label>");
                            label.insertAfter($(input));
                            label.css("left",$(input).offset().left+"px");
                            return label;
                        }
                    }
                ]
            });
            form.jqxValidator('updatePosition');
        },
        destroy: function (form, elem) {
            form.jqxValidator({
                position: 'right',
                rules: []
            });
            form.jqxValidator('updatePosition');
        }
    };
    $(function () {
        tools.init();
        menu.init();
        var oTable = new TableInit();
        oTable.Init();
        tools.rootRuleData(rule.subRuleList, $("#ruleAddModelForm .subTable"));
        resize.init();
        draggables.init();
        rule.init();
        modelType.init();
        validateFun.init();
        var oTable2 = new TableInit2();
        oTable2.Init($("#standardTable"), []);
        var oTable3 = new TableInit3();
        oTable3.Init($("#customTable"), []);
    })
</script>
</body>
</html>